summaryrefslogtreecommitdiffstats
path: root/common/rfb/PixelFormat.inl
diff options
context:
space:
mode:
Diffstat (limited to 'common/rfb/PixelFormat.inl')
-rw-r--r--common/rfb/PixelFormat.inl9
1 files changed, 9 insertions, 0 deletions
diff --git a/common/rfb/PixelFormat.inl b/common/rfb/PixelFormat.inl
index 90d8e6da..ca83a305 100644
--- a/common/rfb/PixelFormat.inl
+++ b/common/rfb/PixelFormat.inl
@@ -75,9 +75,16 @@ inline void PixelFormat::bufferFromPixel(rdr::U8* buffer, Pixel p) const
}
+#define _rfb_bswap_32(x) \
+ ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \
+ (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
+
+
inline void PixelFormat::rgbFromPixel(Pixel p, ColourMap* cm, rdr::U16 *r, rdr::U16 *g, rdr::U16 *b) const
{
if (trueColour) {
+ if (endianMismatch)
+ p = _rfb_bswap_32(p);
/* We don't need to mask since we shift out unwanted bits */
*r = (p >> redShift) << redConvShift;
*g = (p >> greenShift) << greenConvShift;
@@ -100,6 +107,8 @@ inline void PixelFormat::rgbFromPixel(Pixel p, ColourMap* cm, rdr::U16 *r, rdr::
inline void PixelFormat::rgbFromPixel(Pixel p, ColourMap* cm, rdr::U8 *r, rdr::U8 *g, rdr::U8 *b) const
{
if (trueColour) {
+ if (endianMismatch)
+ p = _rfb_bswap_32(p);
*r = (p >> redShift) << (redConvShift - 8);
*g = (p >> greenShift) << (greenConvShift - 8);
*b = (p >> blueShift) << (blueConvShift - 8);