Advertisement

Loading bmp's without using windows programming?

Started by August 31, 2002 05:46 AM
3 comments, last by com 22 years, 4 months ago
Is there any way of loading bmp''s without using windows programming becasue trying to include a bmp in windows programming is just a pain in the neck having to create the image dc etc.
You can load any image once you know the file format. Go to www.wotsit.org, I suppose they have the BMP file format description.

Hint : If you have the choice, you may use TGA. They''re a bit easier to load and can handle 32 bits images.
Advertisement
LOL that is cool...i just finished writing a tutorial that deals with how to load/save bmps 10 minutes ago.
You can read it here http://www.runicsoft.com/bmp.php
But i have to warn you: loading them directly is way more complicated then using window''s LoadImage to bring them on a DC



------------
Runicsoft
Loading an image in windows (bmp) is quite easy. Try this:

HBITMAP l_hBMP=(HBITMAP)LoadImage(GetModuleHandle(0),"yourbitmap.bmp",IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE);
BITMAP l_BMP;

if (l_hBMP)
{
GetObject(l_hBMP, sizeof(l_BMP), &l_BMP);
// i use this in my current project: l_pTexture->iGenTexture(l_BMP.bmWidth, l_BMP.bmHeight, GRI_COLOR_BGR, l_BMP.bmBits);
// now the raw bitmap data in BGR order is lcated at l_BMP.bmBits, and in the prevoius line you can see how to get the width and all too...
DeleteObject(l_hBMP);
}

This works fine for me... thanks to NeHe''s lesson 37 (the last one)

p.s: please excuse me for not using those weird codes for text formatting...
If you want to be able to load a bitmap independant of windows and don''t want to have to write the program yourself, just find a library that lets you do it. Allegro and SDL both have methods for doing it I believe, and both produce platform-independant code.

This topic is closed to new replies.

Advertisement