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

ICOReader does not read AND mask for 16bpp/24bpp ico

    XMLWordPrintable

Details

    • All
    • 1079b5373 (dev), 31a3e82b7 (6.6), 8b20f5c21 (6.5), 8a8dc88d7 (tqtc/lts-5.15)

    Description

      QImageReader/ICOReader does not read the AND mask for 24bpp icon entries in .ico files, causing some icons to have opaque pixels that are supposed to be transparent. Qt uses the same codepath for 32-bit icons as it does 24-bit icons, because icoAttrib.depth is folded to 32 for 16, 24 and 32-bit icons.

      The logic is here:

      if (icoAttrib.depth == 32) {
          img = std::move(image).convertToFormat(QImage::Format_ARGB32_Premultiplied);
      } else {
          QImage mask(image.width(), image.height(), QImage::Format_Mono);
          if (!mask.isNull()) {
              mask.setColorCount(2);
              mask.setColor(0, qRgba(255,255,255,0xff));
              mask.setColor(1, qRgba(0  ,0  ,0  ,0xff));
              read1BitBMP(mask);
              if (!mask.isNull()) {
                  img = image;
                  img.setAlphaChannel(mask);
              }
          }
      } 

      I think that icoAttrib.depth == 32 should possibly be icoAttrib.nbits == 32. This would still use the alpha channel when it is available, but otherwise, it will correctly read the mask.

      Attached is an example of an icon with such a problem, extracted from a program called HookShark. It works with most other software that reads .ico files, including GIMP, and I believe most (all?) versions of Windows that support 24bpp icons.

      Attachments

        For Gerrit Dashboard: QTBUG-113319
        # Subject Branch Project Status CR V

        Activity

          People

            vgt Eirik Aavitsland
            jchw John Chadwick
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There is 1 open Gerrit change