Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-96012

QtWin::imageFromHBITMAP() does never return QtWin::HBitmapAlpha format

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.15.2
    • Extras: Win
    • None
    • Windows 10
    • Windows

    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:
          ...
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            owolff Oliver Wolff
            vladimir.kraus Vladimir Kraus
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes