PDA

View Full Version : QImage Restricted to 256 Pixels?



strateng
1st April 2010, 01:58
Hey,

I was just wondering about QImage if its only restricted to 256 pixels to be displayed and if there was another format I could use to correct QImage or another class similar to QImage I can use to create images through pixels.

The following is the coding I used:


QImage image (13,20, QImage::Format_Indexed8);
QRgb value;
value = qRgb (240,240,240);
image.setColor (256, value);


The following error is what I receive when I attempt to assign 260 Pixels:

QImage::setColor: Index out of bound 256
QImage::setColor: Index out of bound 257
QImage::setColor: Index out of bound 258
QImage::setColor: Index out of bound 259
QImage::setPixel: Index 257 out of range
QImage::setPixel: Index 258 out of range
QImage::setPixel: Index 259 out of range

Thanks,
Strateng

aamer4yu
1st April 2010, 06:38
From the docs -

void QImage::setColor ( int index, QRgb colorValue )
Sets the color at the given index in the color table, to the given to colorValue. The color value is an ARGB quadruplet.

And since you have taken QImage::Format_Indexed8 format, I bet even 9 should give you an error ! (Am not sure though how index table works,, but you can check if am right or wrong )

boudie
1st April 2010, 12:25
Format_indexed8 means you are using an 8bit *colortable* that may contain 256 colorvalues, thus counting from 0..255.

When you do: setPixel(256, ...), or setColor(256, ...)
you are asking for the color at location 256, which is beyond the maximum address.

strateng
6th April 2010, 01:51
Format_indexed8 means you are using an 8bit *colortable* that may contain 256 colorvalues, thus counting from 0..255.

When you do: setPixel(256, ...), or setColor(256, ...)
you are asking for the color at location 256, which is beyond the maximum address.

Thanks for the replies, but I was able to figure out a way to fix the problem I was having. I realised I was only limited by the number of colours and not limited by the number of pixels able to be displayed.