Jump to content
  • Advertisement

Archived

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

com

Loading bmp's without using windows programming?

This topic is 5805 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
Advertisement
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.

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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!