From 13c0fb137d95cffd36a2ffee97cf015702df3748 Mon Sep 17 00:00:00 2001 From: Viktor Arvidsson Date: Sun, 10 Apr 2022 02:57:06 +0200 Subject: Correctly read and write CF_DIB bmp data When decoding CF_DIB data through the bmp handler we have to do some assumptions on where the pixel data starts since there's no file header to get the offset value from. We have to do this because theres some optional data after the info header that needs to be skipped over in some cases. These optional color mask values are now also written when putting a CF_DIB into the clipboard for maximum compatibility with other apps on Windows. This fixes the issue where pasted dibs would be offset by 3 pixels on Windows. Fixes: QTBUG-100351 Pick-to: 6.2 6.3 Change-Id: Icafaf82e0aa3476794b671c638455402a0d5206f Reviewed-by: Eirik Aavitsland --- src/plugins/platforms/windows/qwindowsmime.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/plugins/platforms/windows/qwindowsmime.cpp') diff --git a/src/plugins/platforms/windows/qwindowsmime.cpp b/src/plugins/platforms/windows/qwindowsmime.cpp index 555c3f11b7..a2e35687d7 100644 --- a/src/plugins/platforms/windows/qwindowsmime.cpp +++ b/src/plugins/platforms/windows/qwindowsmime.cpp @@ -177,6 +177,18 @@ static bool qt_write_dibv5(QDataStream &s, QImage image) if (s.status() != QDataStream::Ok) return false; + d->write(reinterpret_cast(&bi.bV5RedMask), sizeof(bi.bV5RedMask)); + if (s.status() != QDataStream::Ok) + return false; + + d->write(reinterpret_cast(&bi.bV5GreenMask), sizeof(bi.bV5GreenMask)); + if (s.status() != QDataStream::Ok) + return false; + + d->write(reinterpret_cast(&bi.bV5BlueMask), sizeof(bi.bV5BlueMask)); + if (s.status() != QDataStream::Ok) + return false; + if (image.format() != QImage::Format_ARGB32) image = image.convertToFormat(QImage::Format_ARGB32); -- cgit v1.2.3