Just create a pixmap of the right size and use QPainter:
Qt Code:
for each letter: rect.moveTo( ... ); p.fillRect( rect, ... ); p.end();To copy to clipboard, switch view to plain text mode
Just create a pixmap of the right size and use QPainter:
Qt Code:
for each letter: rect.moveTo( ... ); p.fillRect( rect, ... ); p.end();To copy to clipboard, switch view to plain text mode
Morea (17th November 2006)
Hi,
Are you sure taht you can use QPixmap? You only can create the image with XPM format.
If you use QImage you would be able to acces directly to the image pointer stored in uchar* by using "bits()". If the image would be a RGB you have to define that the QImage will be a RGB image.
Then you could read the string. For every character you could take the letter and use the proper RGB value (use the macro QRbg(int,int,int)). For example:
You read "b"(black), so the color is QRgb(255,255,255).
You read "w"(white), so the color is QRgb(0,0,0).
I don't remeber if I inverted the values. Black = 0,0,0 and Withe = 255,255,255 ? Try it.
Now, you have wich color is the character that you readed, you have to insert it 20 times in the "bits()" pointer. It is a pointer to an array, so you could index it like "data[i]".
You have to create the image with a width*20 and height*20.
It probably be more easy to program if you index the image with setPixel that you are able to index the 20*20 rectangle putting the QRgb value.
Òscar Llarch i Galán
Ups, sorry for confusing.
The QPainter solution is easyier.
Òscar Llarch i Galán
I would also suggest working with a QImage, which allows pixel-precise manipulation. You can always convert it to a QPixmap later.
i.e.
Qt Code:
for(int i=0;i<400;i++) { QRgb rgb = string[i]=='b' ? qRgb(0,0,0) : qRgb(255,255,255); image.setPixel(i%20, i/20, rgb); }To copy to clipboard, switch view to plain text mode
Bookmarks