aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2010-10-13 10:45:21 +0000
committerPierre Ossman <ossman@cendio.se>2010-10-13 10:45:21 +0000
commitf61db64718f889cf2ac7ad038c29cb1434e6f411 (patch)
tree415c456cfd6291fb5dcb0bda430b909a3eaeb775 /common
parent8561b477718ced89bf0610f24e4fe6af1331ea76 (diff)
downloadtigervnc-f61db64718f889cf2ac7ad038c29cb1434e6f411.tar.gz
tigervnc-f61db64718f889cf2ac7ad038c29cb1434e6f411.zip
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
Diffstat (limited to 'common')
-rw-r--r--common/rfb/PixelFormat.cxx24
1 files 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;