From 01cf57395cdac8958675a7904e3ec5304c7e6440 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Thu, 30 Sep 2010 11:53:15 +0000 Subject: [PATCH] Use proper methods for pixel conversion in the cursor code as it previously wasn't handling all cases correctly. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4153 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- common/rfb/Cursor.cxx | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/common/rfb/Cursor.cxx b/common/rfb/Cursor.cxx index c8dc341b..2d077c98 100644 --- a/common/rfb/Cursor.cxx +++ b/common/rfb/Cursor.cxx @@ -88,17 +88,13 @@ rdr::U8* Cursor::getBitmap(Pixel* pix0, Pixel* pix1) memset(source.buf, 0, maskLen()); int maskBytesPerRow = (width() + 7) / 8; + const rdr::U8 *data_ptr = data; for (int y = 0; y < height(); y++) { for (int x = 0; x < width(); x++) { int byte = y * maskBytesPerRow + x / 8; int bit = 7 - x % 8; if (mask.buf[byte] & (1 << bit)) { - Pixel pix=0; - switch (getPF().bpp) { - case 8: pix = ((rdr::U8*) data)[y * width() + x]; break; - case 16: pix = ((rdr::U16*)data)[y * width() + x]; break; - case 32: pix = ((rdr::U32*)data)[y * width() + x]; break; - } + Pixel pix = getPF().pixelFromBuffer(data_ptr); if (!gotPix0 || pix == *pix0) { gotPix0 = true; *pix0 = pix; @@ -111,6 +107,7 @@ rdr::U8* Cursor::getBitmap(Pixel* pix0, Pixel* pix1) return 0; } } + data_ptr += getPF().bpp/8; } } return source.takeBuf(); -- 2.39.5