I found an example in the codebase that uses some messy bit-twiddling to get the individual r,g,b fields out of a packed rgb float. Is there a nice utility function for doing this?
(I'm trying to avoid unnecessary copy-pasting)
Originally posted by mattbell on ROS Answers with karma: 11 on 2011-02-18
Post score: 1
Original comments
Comment by mattbell on 2011-02-27:
Here's what I ended up doing: uint32_t rgb_val_;
memcpy(&rgb_val_, &(cloud_rgb->points[i].rgb), sizeof(float));
uint8_t r_ = (uint8_t)((rgb_val_ >> 16) & 0x000000ff);
uint8_t g_ = (uint8_t)((rgb_val_ >> 8) & 0x000000ff);
uint8_t b_ = (uint8_t)((rgb_val_) & 0x000000ff);