PDA

View Full Version : Generating .bmp file



aj2903
11th November 2009, 13:11
Hii..

I want to know whether we can create .bmp file using QImage or QImageWriter class.

If we write following code :


QImage imgA;
imgA->setText("","A");
imgA.save("A_bmp.bmp","BMP",-1);


Can A.bmp be generated where it has only text "A" .
Is there any other meathod to implement the same?

yogeshgokul
11th November 2009, 13:21
Can A.bmp be generated where it has only text "A" .
Is there any other meathod to implement the same?
You can also look @ QBitmap.

aj2903
12th November 2009, 07:26
Can some help me regarding QBitmap class.
Is is possible to create new .bmp file using Qt. ?

Can someone give me snippet of the code ?

spirit
12th November 2009, 07:30
what did you try?
did you try something like this?


QPixmap p(100, 100);
p.fill(Qt::red);
p.save("my.bmp", "bmp");

yogeshgokul
12th November 2009, 08:42
Can some help me regarding QBitmap class.
Is is possible to create new .bmp file using Qt. ?Can someone give me snippet of the code ?
Try something like this.

void paint_a_bitmap()
{
QPixmap bmp(500,500);
QPainter p(&bmp);
p.setPen(Qt::red);
p.drawText(200,200,"Qt Painting");
//DO SOME PAINTING HERE
bmp.save("test.bmp");
};