Supporting 16 bit images with Qt
-
wrote on 10 Dec 2019, 08:55 last edited by
Hi,
We have developed a GUI application for loading images to our embedded platform. We need to load 16 bit images from tiff file format. The application uses 32 bit version of Qt 5.12 currently. I am able to load the tiff image in format 25. But this stores pixels in the form of 64 bit word which I cannot access as our application is 32 bit.
I got to know that qt supports 16 bit grayscale images which is okay for us as format 28 is supported in version 5.13. I can port our application to latest one.
I need clarification regarding format 28. Will it automatically convert a 48 bit rgb image to 16 bit? if yes, could you please suggest a way to do it?
Thanks
Sachin -
This gives me error
int WaveFormWindow::quantize(QImage const &src, int bitDepth, QImage *dst)
{
uint08 mask;
uint08 orMask;
uint08 shift;uint16 mask1, orMask1; int minHeight = MIN(dst->height(),src.height()); int minWidth = MIN(dst->width(),src.width()); QImage image = src; uint16 *p = reinterpret_cast<uint16*>(image.scanLine());
}
error: const_cast from 'const uchar *' (aka 'const unsigned char *') to 'uint16 *' (aka 'unsigned short *') is not allowed
I am not able to cast uint08 ptr to uint16 ptr. Please help
Thanks
in advanceRegards
SachinLifetime Qt Championwrote on 11 Dec 2019, 08:32 last edited by jsulm 12 Nov 2019, 08:32@SachinBhat said in Supporting 16 bit images with Qt:
uint16 p = reinterpret_cast<uint16>(image.scanLine());
const uint16 *p = reinterpret_cast<const uint16*>(image.scanLine());
should do...
-
wrote on 10 Dec 2019, 09:06 last edited by
Also, If there is any way I can get the R G and B components of the 16 bit image in 32 bit version of application, then it would make it much easier for me
Thanks
Sachin -
wrote on 10 Dec 2019, 09:21 last edited by
QImage::Format_Grayscale16 28 The image is stored using an 16-bit grayscale format. (added in Qt 5.13)
QImage::Format_RGBX64 25 The image is stored using a 64-bit halfword-ordered RGB(x) format (16-16-16-16). This is the same as the Format_RGBA64 except alpha must always be 65535. (added in Qt 5.12)
QImage::Format_RGBA64 26 The image is stored using a 64-bit halfword-ordered RGBA format (16-16-16-16). (added in Qt 5.12)
QImage::Format_RGBA64_Premultiplied 27 The image is stored using a premultiplied 64-bit halfword-ordered RGBA format (16-16-16-16). (added in Qt 5.12)The formats currently supported in Qt for 16 bit
Thanks
Sachin -
Also, If there is any way I can get the R G and B components of the 16 bit image in 32 bit version of application, then it would make it much easier for me
Thanks
Sachinwrote on 10 Dec 2019, 09:23 last edited byNobody is supposed to know what formats 25 and 28 are.... Qt has symbol to represent formats.
But QImage has bits() and you can read them anyway you like - just get larger chunks for each pixel and its component.
-
wrote on 11 Dec 2019, 07:35 last edited by SachinBhat 12 Nov 2019, 07:36
I use scanLine() to get the pointer of the particular line. But i get a uint08 * pointer. However it would be easy to get a uint16* pointer for processing. Any way to achieve this?
-
I use scanLine() to get the pointer of the particular line. But i get a uint08 * pointer. However it would be easy to get a uint16* pointer for processing. Any way to achieve this?
@SachinBhat said in Supporting 16 bit images with Qt:
Any way to achieve this?
A simple cast of the pointer:
uint16 *p = reinterpret_cast<uint16*>(image.scanLine());
-
wrote on 11 Dec 2019, 08:29 last edited by SachinBhat 12 Nov 2019, 08:29
This gives me error
int WaveFormWindow::quantize(QImage const &src, int bitDepth, QImage *dst)
{
uint08 mask;
uint08 orMask;
uint08 shift;uint16 mask1, orMask1; int minHeight = MIN(dst->height(),src.height()); int minWidth = MIN(dst->width(),src.width()); QImage image = src; uint16 *p = reinterpret_cast<uint16*>(image.scanLine());
}
error: const_cast from 'const uchar *' (aka 'const unsigned char *') to 'uint16 *' (aka 'unsigned short *') is not allowed
I am not able to cast uint08 ptr to uint16 ptr. Please help
Thanks
in advanceRegards
Sachin -
This gives me error
int WaveFormWindow::quantize(QImage const &src, int bitDepth, QImage *dst)
{
uint08 mask;
uint08 orMask;
uint08 shift;uint16 mask1, orMask1; int minHeight = MIN(dst->height(),src.height()); int minWidth = MIN(dst->width(),src.width()); QImage image = src; uint16 *p = reinterpret_cast<uint16*>(image.scanLine());
}
error: const_cast from 'const uchar *' (aka 'const unsigned char *') to 'uint16 *' (aka 'unsigned short *') is not allowed
I am not able to cast uint08 ptr to uint16 ptr. Please help
Thanks
in advanceRegards
SachinLifetime Qt Championwrote on 11 Dec 2019, 08:32 last edited by jsulm 12 Nov 2019, 08:32@SachinBhat said in Supporting 16 bit images with Qt:
uint16 p = reinterpret_cast<uint16>(image.scanLine());
const uint16 *p = reinterpret_cast<const uint16*>(image.scanLine());
should do...
-
wrote on 11 Dec 2019, 08:42 last edited by
Thank you very much for your support
1/9