Bitmaps

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
srg_13

Bitmaps

Post by srg_13 »

Hi,
is it possible to load a .bmp or .jpg file off a disk and display it on the scren, using C? If so, how would this be done??

Stephen :)
mpp.eox3

Re:Bitmaps

Post by mpp.eox3 »

If you don't feel like looking up bmp & jpg file format specifications, there's an quick trick I always use:

Save your images in RAW format (can be done in Photoshop and Paint Shop Pro). This way your data is stored pixel by pixel without any compression/encoding etc.
The only disadvantage is that the file size will be a bit bigger, but who cares..
srg_13

Re:Bitmaps

Post by srg_13 »

OK, I have made a .raw file of the image, but I don't konw how to display it...... ???
mpp.eox3

Re:Bitmaps

Post by mpp.eox3 »

mh.. ok here an example:

if your image is 1600x1200x24bpp, your .raw file will be 5760000 bytes big. The format is as follows ("raw" should say anything shouldn't it?..): RGBRGBRGBRGBRGBRGB...
so all you have to do is memcopy this stuff into your videomem (if you have a 24bpp mode), that's it.
If you have a 32bpp mode, you have to put a 0 in between while copying: 0RGB0RGB0RGB...
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:Bitmaps

Post by Solar »

Stephen, to answer your question more directly:

It is not possible to display a picture only by "using C". The C language has no primitives for displaying graphics. You also need an OS, that provides you with a function to which you pass the binary graphics data, and which in turn does the displaying.

If you are writing your own OS, you have to write that function yourself.

mpp.eox3 hinted to what that function has to do - writing the (uncompressed) picture data to video memory. If that doesn't make it all clear to you ("ah, sure, now that's easy, been there and done that"), your question is not "how do I display a picture", but rather, "how do I display anything?"... and I'd risk a guess then that you don't have a disk driver, file system, or memory handler either... or am I wrong?
Every good solution is obvious once you've found it.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Bitmaps

Post by Pype.Clicker »

the file formats (bitmap, gif, png, jpeg) are described at http://www.wotsit.org ... Once you decoded it, just put color according the screen format in video memory

? how to set a video mode,
? where is video memory and
? what's pixel format will be replied by the VGA standards or the VESA standards (depending on the resolution and colordepth you target).

But aren't you trying to make a splashscreen a bit too early ?
Post Reply