Home > Mobile >  How to use Qt Raw images of 16 bits, it into QImage type
How to use Qt Raw images of 16 bits, it into QImage type

Time:09-17

Now I have some of the original image, CT 3072 * 1944, the size of the two as a pixel, by reading after the assignment does not display properly, please help! (the format of the image set is RGB16, picture is gray but Grayscale8 is eight, tried to also was not used)
Unsigned short * 2=(unsigned short *) malloc (vol * sizeof (unsigned short));

Size_t size=fread (Ii, sizeof (unsigned short), vol, fp);

Int k=0;
for(int j=0; j<1944; J++) {
for(int i=0; i<3072; I++) {

QRgb Value=https://bbs.csdn.net/topics/qRgb (Ii [k], [k], Ii Ii [k]);

Image. SetPixel (I, j, Value);
k++;
}
}
The UI - & gt; Label_2 - & gt; SetPixmap (QPixmap: : fromImage (image));

CodePudding user response:

QImage image (3072, 1944, QImage: : Format_RGB16);
Size_t size=fread (bits, sizeof (unsigned short), vol, fp);
Read such a try, before you should confirm the vol. * 2 should equal the image sizeInBytes ()
And make sure that your image format, 16 a pixel, there are several possible except RGB6 and RGB555 ARGB4444,

CodePudding user response:

Add, to 16 bit and a likely format, is YUV422
If is the YUV cannot use directly on the QImage, have to put data into RGB

CodePudding user response:

Behind the image cannot call sizeInBytes () the function, and then I want to ask how can I look at the pictures the specific format, before they want to see, but could not find method,

CodePudding user response:

Only there's no way to know from raw data format, you have to ask data provider or equipment providers or see the documentation
Or is oneself try one by one, in my experience the 16 bit RGB is not commonly used, more likely to YUV
SizeInBytes () since 5.10 yes, if you are using the old version, just with byteCount ()

CodePudding user response:

Can download a Raw Viewer Raw image Viewer, such as the various formats try one by one
  •  Tags:  
  • Qt
  • Related