C++/graphics
Expert: Eddie - 11/8/2004
QuestionHow can we display bitmap pictures in the program output?
AnswerHello karthik, thank you for the question.
To display bitmaps on screen, in what I'm assuming is a Windows application, the function LoadImage() will load the bitmap info into memory and return a handle to the bitmap, and the function BitBlt will blit the bitmap onto the screen. Remember that one of the things you want to do is draw everything to a "memory" device context, then at the end of all the transformations on the object, blit to the "screen" device context from the memory DC, therefore creating a double buffering like atmosphere. This way, the whole image is being rendered all at once, instead of line by line, and you won't see it being drawn line by line. The following code sample should point you in the right direction:
HBITMAP phBitmap = (HBITMAP)LoadImage( NULL, "NameOfBitmap.bmp",IMAGE_BITMAP, 0, 0,LR_CREATEDIBSECTION | LR_LOADFROMFILE);
// check to see if the bitmap loaded
if(phBitmap == NULL)
MessageBox(NULL, "File Load Error!", "Loading file...", MB_OK);
That gives you your handle to the bitmap, which you can use to manipulate the image. For further information, you can look up the LoadImage function in the MSDN. If you don't have it, you can go to www.msdn.msn.com and look it up there.
I hope this information was helpful.
- Eddie