Skip to content

Commit

Permalink
using PF_BYTE to clean up if elses but it turns out there aren't enou…
Browse files Browse the repository at this point in the history
…gh of those, so have to use ifdef #20
  • Loading branch information
lucasw committed Jul 17, 2018
1 parent 02b6410 commit 00b20d7
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/camera_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,28 @@ class VideoPublisher
image.height = height;
image.width = width;
image.step = pixelsize * width;
// TODO(lucasw) why the RGB BGR reversal- it must be an endian issue
if (pf == Ogre::PF_R8G8B8)
if (pf == Ogre::PF_BYTE_BGR)
image.encoding = sensor_msgs::image_encodings::BGR8;
else if (pf == Ogre::PF_B8G8R8)
else if (pf == Ogre::PF_BYTE_RGB)
image.encoding = sensor_msgs::image_encodings::RGB8;
else if ((pf == Ogre::PF_R8G8B8A8) || (pf == Ogre::PF_X8R8G8B8))
else if (pf == Ogre::PF_BYTE_BGRA)
image.encoding = sensor_msgs::image_encodings::BGRA8;
else if ((pf == Ogre::PF_B8G8R8A8) || (pf == Ogre::PF_X8B8G8R8))
else if (pf == Ogre::PF_BYTE_RGBA)
image.encoding = sensor_msgs::image_encodings::RGBA8;
// There is no PF_BYTE for this or PF_X8R8G8B8
else if (pf == Ogre::PF_X8R8G8B8)
#if OGRE_ENDIAN == OGRE_ENDIAN_BIG
image.encoding = sensor_msgs::image_encodings::RGBA8;
#else
image.encoding = sensor_msgs::image_encodings::BGRA8;
#endif
else if (pf == Ogre::PF_X8B8G8R8)
#if OGRE_ENDIAN == OGRE_ENDIAN_BIG
image.encoding = sensor_msgs::image_encodings::BGRA8;
#else
image.encoding = sensor_msgs::image_encodings::RGBA8;
#endif

// TODO(lucasw) support more encodings
else
{
Expand Down

0 comments on commit 00b20d7

Please sign in to comment.