Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loading Bitmaps

Status
Not open for further replies.

jsteel

Programmer
Feb 11, 2005
17
US
Im trying to load a bitmap image from a file on the hard drive and then dump it onto a ddraw surface. The directx part ive got down, but loading a bitmap is retardedly hard. Where can I find a good source of information for doing this? Everywhere I look doesnt really tell me how to do it. Ive basically given up on LoadImage() and then GetDIBits() because no matter what i do i cant seem to access bitmap.bmBits. How do I do this?
 
This is one way
You could always write your own bitmap reader.

Code:
CBitmap mybitmap;
mybitmap.DeleteObject();
HBITMAP hBitmap = (HBITMAP)LoadImage(NULL, strBmpFileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION | LR_DEFAULTSIZE);
	
if (!hBitmap || !mybitmap.Attach(hBitmap))
    return FALSE;

BITMAP bm;
mybitmap.GetBitmap (&bm);
bm.bmBits ///pointer to the bitmap bits.
 
Thanks. Ill mess around with that for a bit.

I was going to write my own bitmap reader but I decided to try and get it working this way first. I was messing around with the one the Andre Lamothe wrote in Trick of the 3D Game Programming Gurus but it can only read bitmaps that are no larger than the neighborhood of about 1300 x 900, and I cant determine why this is occuring. The application Im using the reader for needs to be able to read bitmaps about twice this size.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top