How to use Pixmap::fromImage() in Jpeg data.
-
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. -
@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.
-
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 ?
-
102410242
-
1024 x 1024 x 2
-
Hi,
Since it's jpeg data, shouldn't you be using QImage::fromData ?
-
@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.
-
-
@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?