Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Pixmap from QImage is broken
QtWS25 Last Chance

Pixmap from QImage is broken

Scheduled Pinned Locked Moved Solved General and Desktop
littlecmspixmapimageimage display
15 Posts 5 Posters 2.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mchinand
    wrote on last edited by mchinand
    #6

    What is the format of the QImage (toDisplay->format())? Can you show exactly what you mean by 'the image is distorted/broken'.

    ademmlerA 1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by Christian Ehrlicher
      #7

      When I run your program, cmsCreateMultiprofileTransform() returns a nullptr and (since I corrected the qDebug - output) get the warning 'Couldn't create color transform !' and then a QMessageBox that the image conversion failed.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      ademmlerA 2 Replies Last reply
      1
      • Christian EhrlicherC Christian Ehrlicher

        When I run your program, cmsCreateMultiprofileTransform() returns a nullptr and (since I corrected the qDebug - output) get the warning 'Couldn't create color transform !' and then a QMessageBox that the image conversion failed.

        ademmlerA Offline
        ademmlerA Offline
        ademmler
        wrote on last edited by ademmler
        #8

        @Christian-Ehrlicher thx for your response.

        I have corrected my code - as you mentioned - but I do not get this warning.
        I get an broken image displayed. Here is a screenshot:
        http://code.ademmler.com/gvimg01.png

        And here is what qt saved to hard disk:
        http://code.ademmler.com/toDisplay.jpg

        Note:
        I have also contacted the author of little CMS - he wrote this sample code.
        I got stuck between opinions and thoughts

        1 Reply Last reply
        0
        • M mchinand

          What is the format of the QImage (toDisplay->format())? Can you show exactly what you mean by 'the image is distorted/broken'.

          ademmlerA Offline
          ademmlerA Offline
          ademmler
          wrote on last edited by ademmler
          #9

          @mchinand https://littlecms.com/blog/2020/12/09/using-lcms2-on-qt/

          little cmd uses a different format than qt - that is what the author wrote about it.
          I just try to create a working minimal sample ...

          Here is what the resulting image looks like:
          http://code.ademmler.com/gvimg01.png

          And here is what qt saved to hard disk:
          http://code.ademmler.com/toDisplay.jpg

          1 Reply Last reply
          0
          • ademmlerA Offline
            ademmlerA Offline
            ademmler
            wrote on last edited by
            #10

            And here is the pixmap saved to hard disk:
            http://code.ademmler.com/qtPixmap.jpg

            Which is also ok - hence I do not understand what's going wrong with displaying this ...

            J.HilkJ 1 Reply Last reply
            0
            • ademmlerA ademmler

              And here is the pixmap saved to hard disk:
              http://code.ademmler.com/qtPixmap.jpg

              Which is also ok - hence I do not understand what's going wrong with displaying this ...

              J.HilkJ Offline
              J.HilkJ Offline
              J.Hilk
              Moderators
              wrote on last edited by
              #11

              @ademmler have you checked the format of toDisplay ? Image::save does take guesses if the format is missing or wrong.
              Also you should check the return type of save, in case saving fails and you actually see the file of a previous attempt


              Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


              Q: What's that?
              A: It's blue light.
              Q: What does it do?
              A: It turns blue.

              ademmlerA 2 Replies Last reply
              0
              • Christian EhrlicherC Christian Ehrlicher

                When I run your program, cmsCreateMultiprofileTransform() returns a nullptr and (since I corrected the qDebug - output) get the warning 'Couldn't create color transform !' and then a QMessageBox that the image conversion failed.

                ademmlerA Offline
                ademmlerA Offline
                ademmler
                wrote on last edited by
                #12

                @Christian-Ehrlicher said in Pixmap from QImage is broken:

                When I run your program, cmsCreateMultiprofileTransform() returns a nullptr and (since I corrected the qDebug - output) get the warning 'Couldn't create color transform !' and then a QMessageBox that the image conversion failed.

                Are you working on MacOS or Windows?
                Have you littlecms installed ? Or checked if you can use the libs I provided?

                1 Reply Last reply
                0
                • J.HilkJ J.Hilk

                  @ademmler have you checked the format of toDisplay ? Image::save does take guesses if the format is missing or wrong.
                  Also you should check the return type of save, in case saving fails and you actually see the file of a previous attempt

                  ademmlerA Offline
                  ademmlerA Offline
                  ademmler
                  wrote on last edited by
                  #13

                  @J-Hilk Gold idea - I will check.

                  1 Reply Last reply
                  0
                  • J.HilkJ J.Hilk

                    @ademmler have you checked the format of toDisplay ? Image::save does take guesses if the format is missing or wrong.
                    Also you should check the return type of save, in case saving fails and you actually see the file of a previous attempt

                    ademmlerA Offline
                    ademmlerA Offline
                    ademmler
                    wrote on last edited by
                    #14

                    @J-Hilk

                    Here is what I see in the debugger. Looks like all "images" have content.
                    http://code.ademmler.com/debugger.png

                    Pls - where can I see the "return value type" in this window?

                    1 Reply Last reply
                    0
                    • ademmlerA Offline
                      ademmlerA Offline
                      ademmler
                      wrote on last edited by ademmler
                      #15

                      Here is the reason and solution. Thanks to Marti Maria - the author of littlecms -
                      to sort this out ...

                      This program does not work because you missed the part on
                      https://littlecms.com/blog/2020/12/09/using-lcms2-on-qt/ that says:

                      Alpha channels are supported as long as the image is not using premultiplied alpha. To get alpha channel make sure to include cmsFLAGS_COPY_ALPHA in the flags field. This is explained in LittleCMS documentation.

                      So, try: toDisplay = colorManage(sourceImage, profiles, INTENT_PERCEPTUAL, cmsFLAGS_COPY_ALPHA);*

                      This fixed the issue for me.

                      1 Reply Last reply
                      2

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved