[Qt-interest] How to show Mono8 images?

Matthias Pospiech matthias.pospiech at gmx.de
Wed Jul 28 13:09:02 CEST 2010


¶­Â¡³¬ schrieb:
> I also try to convert it into RGB32 format and it works well except time and CPU problem.
>   
I am using such code to convert it. It takes about 20ms for conversion 
from mono to rgb for a 1.3 MP image
If you know a faster method let me know.

void QCameraSMX::convertMonoToRGBArray()
{
delete [] d->frameArrayRgb;
d->frameArrayRgb = new TRgbPix[viewSize()];
TRgbPix pixel;

if (bitDepth() == 8) {
// convert 8 bit into 24 Bit Array

int size = viewSize();
for (int i = 0; i < size; ++i)
{
BYTE gray = d->frameArray[i];
pixel.r = gray;
pixel.g = gray;
pixel.b = gray;
d->frameArrayRgb[i] = pixel;
}
} else {
...
}
}

void QCameraSMX::convertRGBtoQImage()
{
if (!d->imageReady) {
d->image = QImage(
(uchar*)d->frameArrayRgb,
viewPort().width(),
viewPort().height(),
QImage::Format_RGB888);
d->image.setColorCount(8);
d->imageReady = true;
}
}



More information about the Qt-interest-old mailing list