Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Commit

Permalink
Fixup #1519: Correctly (and efficiently) handle 3-byte pixel formats (#4
Browse files Browse the repository at this point in the history
)

Co-authored-by: Wolf Vollprecht <w.vollprecht@gmail.com>
  • Loading branch information
seanyen and wolfv authored Oct 16, 2020
1 parent ecfa081 commit c829b3a
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 @@ -589,14 +589,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 c829b3a

Please sign in to comment.