From: Pierre Ossman Date: Thu, 30 Sep 2010 11:53:15 +0000 (+0000) Subject: Use proper methods for pixel conversion in the cursor code as it previously X-Git-Tag: v1.0.90~161 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=01cf57395cdac8958675a7904e3ec5304c7e6440;p=tigervnc.git 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 --- 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();