diff options
author | Pierre Ossman <ossman@cendio.se> | 2010-09-30 11:53:15 +0000 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2010-09-30 11:53:15 +0000 |
commit | 01cf57395cdac8958675a7904e3ec5304c7e6440 (patch) | |
tree | 7d9a2457e9c4b9efd6e18786f75cbe5d8374a215 | |
parent | 7c4efd785e0f260d6f656f50fc49b5dff212b5a9 (diff) | |
download | tigervnc-01cf57395cdac8958675a7904e3ec5304c7e6440.tar.gz tigervnc-01cf57395cdac8958675a7904e3ec5304c7e6440.zip |
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
-rw-r--r-- | common/rfb/Cursor.cxx | 9 |
1 files 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(); |