QWindowsCursor: create correct DDB in createBitmapCursor()
CreateCursor() expects a ddb and according the docs a ddb must be word-aligned but we created a byte-aligned ddb which results in a wrongly rendered cursor later on. Pick-to: 6.6 Task-number: QTBUG-82434 Change-Id: Ie847865a0d868043571faf4b7f4fdf6a92fce448 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> (cherry picked from commit af0edfbc7c33261d11b559cb4842045457adc4a1) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
264dab9936
commit
b63f92bb0f
@ -105,14 +105,16 @@ static HCURSOR createBitmapCursor(const QImage &bbits, const QImage &mbits,
|
||||
hotSpot.setX(width / 2);
|
||||
if (hotSpot.y() < 0)
|
||||
hotSpot.setY(height / 2);
|
||||
const int n = qMax(1, width / 8);
|
||||
QScopedArrayPointer<uchar> xBits(new uchar[height * n]);
|
||||
QScopedArrayPointer<uchar> xMask(new uchar[height * n]);
|
||||
// a ddb is word aligned, QImage depends on bow it was created
|
||||
const auto bplDdb = qMax(1, ((width + 15) >> 4) << 1);
|
||||
const auto bplImg = int(bbits.bytesPerLine());
|
||||
QScopedArrayPointer<uchar> xBits(new uchar[height * bplDdb]);
|
||||
QScopedArrayPointer<uchar> xMask(new uchar[height * bplDdb]);
|
||||
int x = 0;
|
||||
for (int i = 0; i < height; ++i) {
|
||||
const uchar *bits = bbits.constScanLine(i);
|
||||
const uchar *mask = mbits.constScanLine(i);
|
||||
for (int j = 0; j < n; ++j) {
|
||||
for (int j = 0; j < bplImg && j < bplDdb; ++j) {
|
||||
uchar b = bits[j];
|
||||
uchar m = mask[j];
|
||||
if (invb)
|
||||
@ -123,6 +125,11 @@ static HCURSOR createBitmapCursor(const QImage &bbits, const QImage &mbits,
|
||||
xMask[x] = b ^ m;
|
||||
++x;
|
||||
}
|
||||
for (int i = bplImg; i < bplDdb; ++i) {
|
||||
xBits[x] = 0;
|
||||
xMask[x] = 0;
|
||||
++x;
|
||||
}
|
||||
}
|
||||
return CreateCursor(GetModuleHandle(nullptr), hotSpot.x(), hotSpot.y(), width, height,
|
||||
xBits.data(), xMask.data());
|
||||
|
Loading…
x
Reference in New Issue
Block a user