Skip to content

Commit

Permalink
cleanup to remove topIsLow from yarp::sig::Image
Browse files Browse the repository at this point in the history
  • Loading branch information
randaz81 committed Dec 4, 2024
1 parent ca14395 commit 6715711
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
3 changes: 1 addition & 2 deletions src/libYARP_sig/src/yarp/sig/Image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,11 @@ inline bool readFromConnection(Image &dest, ImageNetworkHeader &header, Connecti
//this check is redundant with assertion, I would remove it
if (dest.getRawImageSize() != static_cast<size_t>(header.imgSize)) {
printf("There is a problem reading an image\n");
printf("incoming: width %zu, height %zu, code %zu, quantum %zu, topIsLow %zu, size %zu\n",
printf("incoming: width %zu, height %zu, code %zu, quantum %zu, size %zu\n",
static_cast<size_t>(header.width),
static_cast<size_t>(header.height),
static_cast<size_t>(header.id),
static_cast<size_t>(header.quantum),
static_cast<size_t>(header.topIsLow),
static_cast<size_t>(header.imgSize));
printf("my space: width %zu, height %zu, code %d, quantum %zu, size %zu\n",
dest.width(), dest.height(), dest.getPixelCode(), dest.getQuantum(), allocatedBytes);
Expand Down
20 changes: 10 additions & 10 deletions src/libYARP_sig/src/yarp/sig/ImageNetworkHeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,10 @@ class ImageNetworkHeader
const yarp::os::NetInt32 paramIdTag{BOTTLE_TAG_VOCAB32};
yarp::os::NetInt32 id{0};
const yarp::os::NetInt32 paramListTag{BOTTLE_TAG_LIST + BOTTLE_TAG_INT32};
// WARNING This is 5 and not 6 because quantum and topIsLow are
// transmitted in the same 32 bits for compatibility with
// YARP 3.4 and older
const yarp::os::NetInt32 paramListLen{5};
yarp::os::NetInt32 depth{0};
yarp::os::NetInt32 imgSize{0};
yarp::os::NetInt16 quantum{0};
// WARNING The topIsLowIndex field in the ImageNetworkHeader is `0` for
// `true` and `1` for `false` for compatibility with YARP 3.4
// and older
yarp::os::NetInt16 topIsLow{0};
yarp::os::NetInt32 quantum{0};
yarp::os::NetInt32 width{0};
yarp::os::NetInt32 height{0};
const yarp::os::NetInt32 paramBlobTag{BOTTLE_TAG_BLOB};
Expand All @@ -52,12 +45,19 @@ class ImageNetworkHeader
id = image.getPixelCode();
depth = image.getPixelSize();
imgSize = image.getRawImageSize();
quantum = static_cast<yarp::os::NetInt16>(image.getQuantum());
topIsLow = 1;
quantum = image.getQuantum();
width = image.width();
height = image.height();
paramBlobLen = image.getRawImageSize();
}

void setToImage(FlexImage& image)
{
image.setPixelCode(id);
//setPixelSize() is already set by setPixelCode
image.setQuantum(quantum);
image.resize(width, height);
}
};
YARP_END_PACK

Expand Down

0 comments on commit 6715711

Please sign in to comment.