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 c8dc341..2d077c9 100644
--- a/common/rfb/Cursor.cxx
+++ b/common/rfb/Cursor.cxx
@@ -88,17 +88,13 @@
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 @@
return 0;
}
}
+ data_ptr += getPF().bpp/8;
}
}
return source.takeBuf();