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::loadFromData
Forum Updated to NodeBB v4.3 + New Features

QImage::loadFromData

Scheduled Pinned Locked Moved General and Desktop
14 Posts 2 Posters 4.5k 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.
  • O Offline
    O Offline
    opengpu2
    wrote on last edited by
    #1

    QImage::loadFromData(const uchar * data, int len, const char * format = 0)
    what is exactly the len is? byte? how about the pitch?
    i use this API to load a memory data of DDS file with MipMap...
    but whatever i tried, all failed......

    anyone know any successful demo of use this API?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      As an example take a web server that streams jpg images, you can build a QImage from the data received (once you have all the data that is)

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      O 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        As an example take a web server that streams jpg images, you can build a QImage from the data received (once you have all the data that is)

        O Offline
        O Offline
        opengpu2
        wrote on last edited by
        #3

        @SGaist sorry? but i am not quite sure i know what u mean...
        i just doubt that i send a wrong len as the param.... but i dont know what is the right value that should be set, as for a DDS file with Mipmap, considering the Pitch.....

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Len should be number of byte of your image. Using this function, Qt will try to guess the format unless you give it him and use the proper reader if it has one for that format

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • O Offline
            O Offline
            opengpu2
            wrote on last edited by
            #5

            but when i tried to load a DDS file which is BC5 with mipmap, always failed....
            so i wonder if i set the wrong len, considering the Pitch...
            how to set the len if there is a Pitch?

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              What error message do you get ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • O Offline
                O Offline
                opengpu2
                wrote on last edited by
                #7

                just return false....and so i donot know what error it was...

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Did you check that you have the dds plugin ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • O Offline
                    O Offline
                    opengpu2
                    wrote on last edited by
                    #9

                    i donot use dds plugin...i use my own way to open the image file and copy the memory to the QImage through QImage::loadFromData

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      loadFromData expects an Image of a known format, or you should provide your own plugin to read the data. If you want to use raw bytes then you should use one of the QImage constructors dedicated to that.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • O Offline
                        O Offline
                        opengpu2
                        wrote on last edited by
                        #11

                        the format i do know, is DDS...but it's DDS BC5...and the plugin can't show it...that's why i have to copy the memory to the QImage by myself...
                        how can i use one of the QImage constructors dedicated to that ??
                        i am not quite sure about this....is there example?

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          As silly as it may sound, just provide the data the specific constructor needs to have

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          0
                          • O Offline
                            O Offline
                            opengpu2
                            wrote on last edited by opengpu2
                            #13

                            `
                            QImage(uchar * data, int width, int height, Format format, QImageCleanupFunction cleanupFunction = 0, void * cleanupInfo = 0)

                            QImage(const uchar * data, int width, int height, Format format, QImageCleanupFunction cleanupFunction = 0, void * cleanupInfo = 0)

                            QImage(uchar * data, int width, int height, int bytesPerLine, Format format, QImageCleanupFunction cleanupFunction = 0, void * cleanupInfo = 0)

                            QImage(const uchar * data, int width, int height, int bytesPerLine, Format format, QImageCleanupFunction cleanupFunction = 0, void * cleanupInfo = 0)

                            QImage(const char * const[] xpm)
                            `

                            1 Reply Last reply
                            0
                            • O Offline
                              O Offline
                              opengpu2
                              wrote on last edited by
                              #14

                              use these two?
                              QImage(uchar * data, int width, int height, int bytesPerLine, Format format, QImageCleanupFunction cleanupFunction = 0, void * cleanupInfo = 0)

                              QImage(const uchar * data, int width, int height, int bytesPerLine, Format format, QImageCleanupFunction cleanupFunction = 0, void * cleanupInfo = 0)

                              1 Reply Last reply
                              0

                              • Login

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