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. How to use Pixmap::fromImage() in Jpeg data.
Forum Updated to NodeBB v4.3 + New Features

How to use Pixmap::fromImage() in Jpeg data.

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 3 Posters 899 Views 1 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.
  • D Offline
    D Offline
    DaTranShan
    wrote on last edited by aha_1980
    #1

    Hi there, I have a data stream in a struct transform from another thread and I want to Load it and show it.

    QImage((uchar*)pbyteImage,1024,1024,2,QImage::Format_RGB32);
    this->setPixmap(QPixmap::fromImage(img_in));
    

    The question is which the Format should I use?
    I will be grateful for your replies.

    jsulmJ 1 Reply Last reply
    0
    • D DaTranShan

      Hi there, I have a data stream in a struct transform from another thread and I want to Load it and show it.

      QImage((uchar*)pbyteImage,1024,1024,2,QImage::Format_RGB32);
      this->setPixmap(QPixmap::fromImage(img_in));
      

      The question is which the Format should I use?
      I will be grateful for your replies.

      jsulmJ Online
      jsulmJ Online
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @DaTranShan said in How to use Pixmap::fromImage() in Jped data.:

      The question is which the Format should I use?

      The one you get from the stream I would say. You should know what format is used to put the data into the stream.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      D 1 Reply Last reply
      0
      • D Offline
        D Offline
        DaTranShan
        wrote on last edited by
        #3

        Sorry about that I missed that, which is Jpeg buffer size 102410242 in uint32. I can understand 1024*1024 is the size of that. But 2 which means ?

        1 Reply Last reply
        0
        • D Offline
          D Offline
          DaTranShan
          wrote on last edited by
          #4

          102410242

          1 Reply Last reply
          0
          • D Offline
            D Offline
            DaTranShan
            wrote on last edited by
            #5

            1024 x 1024 x 2

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

              Hi,

              Since it's jpeg data, shouldn't you be using QImage::fromData ?

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

              D 1 Reply Last reply
              0
              • SGaistS SGaist

                Hi,

                Since it's jpeg data, shouldn't you be using QImage::fromData ?

                D Offline
                D Offline
                DaTranShan
                wrote on last edited by
                #7

                @SGaist Yeah!!! Thank you, sir. I used

                            QImage img_in;
                            img_in.loadFromData(pbyteImage,size,"JPG");
                

                Load the pic normally. As I thought, QImage maybe could use his constructor loading the pic. Do you know how can I use that? Or that can't do that, but Why? Thank you for that.

                1 Reply Last reply
                0
                • jsulmJ jsulm

                  @DaTranShan said in How to use Pixmap::fromImage() in Jped data.:

                  The question is which the Format should I use?

                  The one you get from the stream I would say. You should know what format is used to put the data into the stream.

                  D Offline
                  D Offline
                  DaTranShan
                  wrote on last edited by
                  #8

                  @jsulm Hi jsulm, according to @SGaist advice I could use QImage.loadFromData function to load the pic. But I still think the QImage constructor could do that too. Do you think so, and how can I do that? Sincerely thanks for your replies.

                  jsulmJ 1 Reply Last reply
                  0
                  • D DaTranShan

                    @jsulm Hi jsulm, according to @SGaist advice I could use QImage.loadFromData function to load the pic. But I still think the QImage constructor could do that too. Do you think so, and how can I do that? Sincerely thanks for your replies.

                    jsulmJ Online
                    jsulmJ Online
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    @DaTranShan You can use static QImage::fromData method:

                    QImage img_in = QImage::fromData(pbyteImage,size,"JPG");
                    

                    If you insist in using one of the constructors (for whatever reason) there are some of them described in the documentation (like https://doc.qt.io/qt-5/qimage.html#QImage-3) - did you check already?

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    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