PDA

View Full Version : How to read and display BMP image just using QT's GUI?



everlasting525
3rd April 2011, 16:22
http://www.kalytta.com/bitmap.h

I'm catching on the course of image processing.So I want to use the above bitmap file loader to read the bitmap without using QImage or any other bulit in qt classes. Then display the bitmap in the qt gui. Any advices?

Thanx a lot in advance.

JohannesMunk
3rd April 2011, 16:51
Hi!

I can't quite see the point! Do you want to draw the bitmap data yourself or use a qt class for that?

If the later you could have a look at the qimage constructors (http://doc.trolltech.com/latest/qimage.html#QImage-6) that take a pointer to raw data. I leave it to you to guess what function of your bitmap library you need to call to get to the data :->

Joh

everlasting525
3rd April 2011, 17:32
Hi, Joh

I want to read and draw the bitmap myself. Later I will also implement more functions learned form the course of image processing myself.
For now how to draw the image after using my bitmap library is my main problem.

ever

wysota
3rd April 2011, 18:00
I also don't see the point, you'll be doing twice as much work as needed. If you want to do the reading yourself then afterwards you have to fill a QImage object with properly formatted data that is probably completely different than the one you have after reading the file. So first you'll be converting data from the file to your own format and then from your own format to what QImage expects. If you don't care about efficiency you can use QImage::setPixel() after you initialize QImage with a proper size and color map. If you do care about efficiency, use QImage::bits() and fill the returned pointer with pixel data in a format chosen earlier for QImage.

But if you want to read and draw the bitmap yourself, what do you need QImage for?

JohannesMunk
3rd April 2011, 19:26
Hi!

I would recommend to leave the drawing of the image to QImage/QPixmap/QLabel and concentrate on the implementation of the image processing.

If you need further (wysota gave you some good hints) help to get your image data displayed in such a way, just let us know.

Drawing the image yourself pixel by pixel e.g. in the paintEvent of some custom widget is utterly slow and will not teach you much if anything worthwhile - if that's what you had in mind.

Good luck with your studies,

Joh

everlasting525
3rd April 2011, 23:57
Thanks for replying. Maybe I should focus on the part of image processing. Not the loading itself.

THANX for your recommendation. I know what i am going to do now.