From f61db64718f889cf2ac7ad038c29cb1434e6f411 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Wed, 13 Oct 2010 10:45:21 +0000 Subject: [PATCH] Converting a integer shift to a byte offset of course depends on endianness as the first byte might be either shift 0 or shift 24. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4165 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- common/rfb/PixelFormat.cxx | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/common/rfb/PixelFormat.cxx b/common/rfb/PixelFormat.cxx index afcf4295..11c2d7ab 100644 --- a/common/rfb/PixelFormat.cxx +++ b/common/rfb/PixelFormat.cxx @@ -187,9 +187,15 @@ void PixelFormat::bufferFromRGB(rdr::U8 *dst, const rdr::U8* src, // Optimised common case rdr::U8 *r, *g, *b; - r = dst + redShift/8; - g = dst + greenShift/8; - b = dst + blueShift/8; + if (bigEndian) { + r = dst + (24 - redShift)/8; + g = dst + (24 - greenShift)/8; + b = dst + (24 - blueShift)/8; + } else { + r = dst + redShift/8; + g = dst + greenShift/8; + b = dst + blueShift/8; + } while (pixels--) { *r = *(src++); @@ -253,9 +259,15 @@ void PixelFormat::rgbFromBuffer(rdr::U8* dst, const rdr::U8* src, int pixels, Co // Optimised common case const rdr::U8 *r, *g, *b; - r = src + redShift/8; - g = src + greenShift/8; - b = src + blueShift/8; + if (bigEndian) { + r = src + (24 - redShift)/8; + g = src + (24 - greenShift)/8; + b = src + (24 - blueShift)/8; + } else { + r = src + redShift/8; + g = src + greenShift/8; + b = src + blueShift/8; + } while (pixels--) { *(dst++) = *r; -- 2.39.5