help with opening image file

A

albo

hi all !!
i need help in opening an image file (bmp)
and printing it to the screen.

thanks
 
F

fool

hi all !!
i need help in opening an image file (bmp)
and printing it to the screen.

thanks

Use fopen and FILE pointer to open the file. The .bmp file starts with BM
in the first two bytes. While reading the file, if the BM string is first
2 bytes then print the file in the screen. If not then throw a error.
Take care while doing the file operations and memory allocations. Hope
this helps.
 
R

Richard Heathfield

albo said:
hi all !!
i need help in opening an image file (bmp)

That bit's easy enough. The bitmap format is relatively well-documented and
reasonably simple. You can find out about it in, say, "Programming
Windows", 5th edition, by Charles Petzold, or you could try something like
http://www.wotsit.org/

So it's literally a question of opening the file using fopen, reading the
various bits of header information, then loading and storing the bitmap
information in some suitable data structure (I use an array of arrays of
unsigned long, but that's not the only possible choice). Don't forget that
bitmaps are sometimes (often, usually) stored the wrong way up.
and printing it to the screen.

That's still pretty easy, but the exact details will depend on your
implementation's graphics library provisions. Consult a newsgroup that
deals with your implementation.
 
M

Malcolm

Richard Heathfield said:
albo said:


That bit's easy enough. The bitmap format is relatively well-documented
and
reasonably simple. You can find out about it in, say, "Programming
Windows", 5th edition, by Charles Petzold, or you could try something like
http://www.wotsit.org/

So it's literally a question of opening the file using fopen, reading the
various bits of header information, then loading and storing the bitmap
information in some suitable data structure (I use an array of arrays of
unsigned long, but that's not the only possible choice). Don't forget that
bitmaps are sometimes (often, usually) stored the wrong way up.


That's still pretty easy, but the exact details will depend on your
implementation's graphics library provisions. Consult a newsgroup that
deals with your implementation.
Why is't there a loader available on the net?
After all, one person needs to write a portable load routine once, and if
he's done a competent job no one need ever worry about the details again.
 
R

Richard Bos

Why is't there a loader available on the net?

Who says there isn't? Do a websearch.
After all, one person needs to write a portable load routine once, and if
he's done a competent job no one need ever worry about the details again.

Hah. Not much experience with M$ shifting specs, have you?

Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top