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. Qimage::save() fails
Qt 6.11 is out! See what's new in the release blog

Qimage::save() fails

Scheduled Pinned Locked Moved Unsolved General and Desktop
17 Posts 6 Posters 6.3k Views 2 Watching
  • 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.
  • SGaistS SGaist

    Hi,

    Can you share the code you use to save the image ?
    How are you building the path ?

    S Offline
    S Offline
    swagat
    wrote on last edited by
    #8

    @SGaist It's a simple QString with a PNG as extention:
    E.g: C:/Data/ARCHIVE/2021Jun04/Reports\TEST-Administrator-FAIL-20210602-194733.png

    JonBJ 1 Reply Last reply
    0
    • S swagat

      @SGaist It's a simple QString with a PNG as extention:
      E.g: C:/Data/ARCHIVE/2021Jun04/Reports\TEST-Administrator-FAIL-20210602-194733.png

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #9

      @swagat
      Verify that if you replace QImage::save(that_path) with, say, QFile::Open(that_path, QIODevice::WriteOnly); at the same point in code it saves.

      C 1 Reply Last reply
      0
      • JonBJ JonB

        @swagat
        Verify that if you replace QImage::save(that_path) with, say, QFile::Open(that_path, QIODevice::WriteOnly); at the same point in code it saves.

        C Offline
        C Offline
        CleverFish
        wrote on last edited by CleverFish
        #10

        @JonB
        Yes, It does create file when replaced with suggested QFile::open() way. That indicates no permission issue.

        JonBJ 1 Reply Last reply
        0
        • C CleverFish

          @JonB
          Yes, It does create file when replaced with suggested QFile::open() way. That indicates no permission issue.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #11

          @CleverFish
          Fair enough. So now what happens if you save the same image via QImage::save(path) with some safe path you are sure you can write to, C:\TEMP or whatever?

          Then we should know whether it's the file path or the image conversion to save which is at issue.

          You could also try saving it to same place but with a different extension, say .jpg, to see whether it could be a png thing.

          C 1 Reply Last reply
          0
          • JonBJ JonB

            @CleverFish
            Fair enough. So now what happens if you save the same image via QImage::save(path) with some safe path you are sure you can write to, C:\TEMP or whatever?

            Then we should know whether it's the file path or the image conversion to save which is at issue.

            You could also try saving it to same place but with a different extension, say .jpg, to see whether it could be a png thing.

            C Offline
            C Offline
            CleverFish
            wrote on last edited by CleverFish
            #12

            @JonB thanks for the response. I did try with.jpg and bmp file format but save() failed returns false.

            JonBJ artwawA 2 Replies Last reply
            0
            • C CleverFish

              @JonB thanks for the response. I did try with.jpg and bmp file format but save() failed returns false.

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by
              #13

              @CleverFish
              Then the save path seems to have nothing to do with it, does it? And it didn't save as other image formats. So presumably either that image is rubbish, or you cannot save any images at all?

              C 1 Reply Last reply
              0
              • C CleverFish

                @JonB thanks for the response. I did try with.jpg and bmp file format but save() failed returns false.

                artwawA Offline
                artwawA Offline
                artwaw
                wrote on last edited by
                #14

                @CleverFish might be dumb to ask but what if you try to save this using QFile? Same parameters for saving.

                For more information please re-read.

                Kind Regards,
                Artur

                C 1 Reply Last reply
                0
                • artwawA artwaw

                  @CleverFish might be dumb to ask but what if you try to save this using QFile? Same parameters for saving.

                  C Offline
                  C Offline
                  CleverFish
                  wrote on last edited by
                  #15

                  @artwaw I tried that too. It's able to create such file.

                  1 Reply Last reply
                  0
                  • JonBJ JonB

                    @CleverFish
                    Then the save path seems to have nothing to do with it, does it? And it didn't save as other image formats. So presumably either that image is rubbish, or you cannot save any images at all?

                    C Offline
                    C Offline
                    CleverFish
                    wrote on last edited by
                    #16

                    @JonB There is a new observation. If the application is lunched using the credentials through which it got installed, it's able to generate the reports without any issues.

                    JonBJ 1 Reply Last reply
                    0
                    • C CleverFish

                      @JonB There is a new observation. If the application is lunched using the credentials through which it got installed, it's able to generate the reports without any issues.

                      JonBJ Offline
                      JonBJ Offline
                      JonB
                      wrote on last edited by JonB
                      #17

                      @CleverFish
                      We are back to possibly permissions. However I also wonder whether the environment --- perhaps the library files for converting to png --- are right for the installer but not for other users. Who knows.

                      Plus, I now notice you are using Qt 4, so goodness knows.

                      I think you should split your convert + save into separate operations. Assuming it exists in Qt 4, bool QImage::save(QIODevice *device, const char *format = nullptr, int quality = -1) const should save to memory. There is an example on that page. First check whether that works. If it does, you can use the QFile you say works to save the buffer to file. See if that works, or report which of the two fails.

                      1 Reply Last reply
                      1

                      • Login

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