Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.15.2
-
None
-
Windows 10
Description
It seems that QtWin::imageFromHBITMAP() always returns premultiplied alpha format and never non-premultiplied format. I tracked this to function in qpixmap_win.cpp
static QImage::Format imageFromWinHBITMAP_Format(const BITMAPINFOHEADER &header, int hbitmapFormat) { QImage::Format result = QImage::Format_Invalid; switch (header.biBitCount) { case 32: result = hbitmapFormat == HBitmapNoAlpha ? QImage::Format_RGB32 : QImage::Format_ARGB32_Premultiplied; break; case 24: ...
But I think it is incorrect because it does not set correctly format for hbitmapFormat == HBitmapAlpha. I believe the correct code should be:
static QImage::Format imageFromWinHBITMAP_Format(const BITMAPINFOHEADER &header, int hbitmapFormat) { QImage::Format result = QImage::Format_Invalid; switch (header.biBitCount) { case 32: switch (hbitmapFormat) { case QtWin::HBitmapNoAlpha: result = QImage::Format_RGB32; break; case QtWin::HBitmapAlpha: result = QImage::Format_ARGB32; break; case QtWin::HBitmapPremultipliedAlpha: result = QImage::Format_ARGB32_Premultiplied; break; } break; case 24: ...