Archived

This topic is now archived and is closed to further replies.

Loading bmp's without using windows programming?

This topic is 5588 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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...

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites