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

Calling QClipboard::image() corrupts image inside Win 11 clipboard memory (from Windows Snipping Tool)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 6.2.6, 6.4.0 RC1, 6.5.0 Beta1
    • 6.3.1
    • QPA: Windows
    • Device model: Dell Inspiron 5593 (15")
      CPU: Intel i7-1065G7
      GPU: Intel Iris Plus + NVIDIA GeForce MX230
      OS: Windows 11 Home 21H2 (build 22000.856)
      Compiler: MSVC 2019 x64
    • Windows
    • 8cb78647e3 (qt/qtbase/dev) 8cb78647e3 (qt/tqtc-qtbase/dev) 8edb27d7df (qt/qtbase/6.4) 8edb27d7df (qt/tqtc-qtbase/6.4) 8edb27d7df (qt/tqtc-qtbase/6.4.0) 6d3f165c9f (qt/tqtc-qtbase/6.2)

    Description

      I'm unsure if the issue lies in Qt or in Windows.

       

      Code

      #include <QtGui>
      
      int main(int argc, char *argv[])
      {
          QGuiApplication app(argc, argv);
          QImage img = app.clipboard()->image();
          img.save("output.bmp"); // Removing this line does not change the outcome
      }
      

       

      Steps to reproduce

      1. Use the Windows Snipping Tool ([Win]+[Shift]+S) to snip anything on screen. For maximum effect, ensure that the left edge of the snipped area has very different colours to the right edge.
      2. Build and run the code above.
      3. Open Microsoft Paint and paste the clipboard contents into Microsoft Paint.

       

      Outcome

      While output.bmp looks OK (like snip-ok.png), the pasted image is corrupted (like snip-corrupted.png).

      It's as if a few columns from the right edge were transferred to the left edge; notice also the 3 red, green, and blue pixels at the bottom-left of the image.

       

      Scope of issue

      • This has been reproduced on a Windows 11 machine, but not Windows 10.
      • If the call to QClipboard::image() and QImage::save() are deleted, then Step #3 doesn't produce a corrupted result. (This suggests it's an issue in Qt)
      • This issue affects images pasted into Microsoft Paint and Microsoft OneNote, but it does not affect images pasted into Microsoft Word or written by img.save("output.bmp")(This suggests it's an issue in Windows)
      • This issue only affects images captured by the Windows Snipping Tool. It does not affect images copied from Microsoft Paint, and does not affect images put in the clipboard via QClipboard::setImage().

      Attachments

        1. snip-corrupted.png
          snip-corrupted.png
          348 kB
        2. snip-ok.png
          snip-ok.png
          486 kB

        Issue Links

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

          Activity

            People

              owolff Oliver Wolff
              skoh-qt Sze Howe Koh
              Votes:
              2 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes