Skip to content

Commit

Permalink
Fixup ros-visualization#1519: Correctly (and efficiently) handle 3-by…
Browse files Browse the repository at this point in the history
…te pixel formats
  • Loading branch information
wolfv authored and seanyen committed Oct 16, 2020
1 parent b0300c3 commit 3813ac5
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/rviz/selection/selection_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,14 +588,10 @@ void SelectionManager::unpackColors(Ogre::PixelBox& box, V_CollObject& pixels)
{
for (int x = 0; x < w; x++)
{
if (size == 4) // In case of a 4-byte color format, we can directly process the 32-bit values
{
uint32_t pos = (x + y * w) * 4;
uint32_t pix_val = *(uint32_t*)((uint8_t*)box.data + pos);
pixels.push_back(colorToHandle(box.format, pix_val));
}
else // otherwise perform "official" transformation into float-based Ogre::ColourValue and back
pixels.push_back(colorToHandle(box.getColourAt(x, y, 1)));
uint32_t pos = (x + y * w) * size;
uint32_t pix_val = 0;
memcpy((uint8_t*)&pix_val, (uint8_t*)box.data + pos, size);
pixels.push_back(colorToHandle(box.format, pix_val));
}
}
}
Expand Down

0 comments on commit 3813ac5

Please sign in to comment.