aboutsummaryrefslogtreecommitdiffstats
path: root/common/rfb/PixelFormat.inl
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2009-04-21 17:30:45 +0000
committerPierre Ossman <ossman@cendio.se>2009-04-21 17:30:45 +0000
commit19dbca236cfc807ffd7c90322dcda158781c289b (patch)
tree0992de2b012a78aa446d00051e3d4b4cde8c6946 /common/rfb/PixelFormat.inl
parent07893cbb127acfdb4879fbc596aea9c89df3f753 (diff)
downloadtigervnc-19dbca236cfc807ffd7c90322dcda158781c289b.tar.gz
tigervnc-19dbca236cfc807ffd7c90322dcda158781c289b.zip
Make sure we handle endian problems in the conversion code.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@3784 3789f03b-4d11-0410-bbf8-ca57d06f2519
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);