Thursday, July 9, 2009

How do you include bitmaps in C++ without using openGL or other such things?

I have the bitmaps drawn out i just need to include them! I cant find out how. Ive seen some code but it had no explanation and I dont understand. Please help

How do you include bitmaps in C++ without using openGL or other such things?
Hmm you need to open the bitmap and then you would need to get a pointer from that bitmap. I don't know where you want to include them but here is how you load the bitmap:





// Loads A Bitmap Image


AUX_RGBImageRec *LoadBMP(char *Filename) {


// File Handle


FILE *File=NULL;


// Make Sure A Filename Was Given


if (!Filename)


{


// If Not Return NULL


return NULL;


}


// Check To See If The File Exists


File=fopen(Filename,"r");


if (File) // Does The File Exist?


{


// Close The Handle


fclose(File);


// Load The Bitmap And Return A Pointer


return auxDIBImageLoad(Filename);


}


// If Load Failed Return NULL


return NULL;


}








The above function loads the bitmap and returns the pointer. So I don't know how you are going to use it, but if it is a simple mfc or a windows layout you would just bind the pointer to some object you created.
Reply:(windows??) Visual C++ ? -%26gt; Picturebox


http://programmersheaven.com


http://codeproject.com


No comments:

Post a Comment