[Qt-interest] Qt-interest Digest, Vol 6, Issue 142
Tim W
timpie.w at gmail.com
Sun May 17 11:08:58 CEST 2009
>One more think.I want to do it on grayscale.I tried to paint the label just
on one pixel but it >shows me a lot of colors.And it is shown in all the
QLabel.Not on a pixel.
>Co
You forgot to set the color table.
Watch out I didn't compile this!
const int width = 500;
const int height = 500;
const int numberOfColors = 256;
QImage img(width, height,QImage::Format_Indexed8);
QVector<QRgb> grayColors(numberOfColors);
for( int i=0 ; i!= numberOfColors ; ++i)
{
grayColors[i] = qRgb(i,i,i);
}
img.setColorTable( grayColors ) ;
//.... fill the image with the uchar values, note scanLine is way faster
then
for(i=0;i< width;i++)
{
for(int k=0;k< height;k++)
{
img.setPixel(i,k, testMap[i][k]);
}
}
ui->showMapLabel->setPixmap(QPixmap::fromImage(img));
---
An Apple a day keeps Windows away
ACCU - http://www.accu.org - Professionalism in Programming.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090517/401c5afc/attachment.html
More information about the Qt-interest-old
mailing list