Home
Tutorials
Code Snippets
Code Samples
Downloads
Links

The Blog
Our Projects
About
Contact

::Add RageStorm to Favorites!::

The Blog | Our Projects | Guest Book | About | Contact

 
Code Snippet - Loading BMP
Author:Arkon
Category:Win32API
File Size:707 Bytes
Uploaded at:27-Nov-02 07:29:52 pm
Description:
  Two ways (file/resource) for loading a .bmp and displaying.
  
HBITMAP hBitmap;

// From File:
hBitmap = (HBITMAP)LoadImage(hInstance, "myimage.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);

// From Resource:
hBitmap = LoadBitmap(MAKEINTRESOURCE(IDB_MYBMP));

Ok we just loaded the .BMP...

BITMAP BMP;
GetObject(hBitmap, sizeof(BMP), &BMP);  // Here we get the BMP header info.

HDC BMPDC = CreateCompatibleDC(NULL); // This will hold the BMP image itself.

HDC hDC = GetDC(hWnd);
SelectObject(BMPDC, hBitmap); // Put the image into the DC.

BitBlt(hDC, X, y, BMP.bmWidth, BMP.bmHeight, BMPDC, 0, 0, SRCCOPY); // Finally, Draw it :)

ReleaseDC(hDC, hWnd);

// Don't forget to clean up!
DeleteDC(BMPDC);
DeleteObject(hBitmap);
NOTE:
Comments that will hurt anyone in any way will be deleted.
Don't ask for features, advertise or curse.
If you want to leave a message to the author use the contacts,
if you have any question in relation to your comments please use the forum.
Comments which violate any of these requests will be deleted without further
notice. Use the comment system decently.

Post your comment:
Name:
email:
Comment:
::Top 5 Tutorials::
Embedded Python[116334]
2D Rotated Rectangles Collision Detection[88465]
Keyboard Hook[76715]
UDP[65655]
HTTP Proxy[41046]

::Top 5 Samples::
2D ColDet Rotated Rectangles[11530]
PS2 Mouse Driver[6927]
Wave Format Player[5763]
Reading FAT12[5590]
CodeGuru[5326]


All rights reserved to RageStorm © 2009