Advertisement
2002C Graphics/ Sound #16522

Load a BMP from a file

This is a simple, easy to use function that shows how to load a bitmap from a file then bitblit it to a window.

AI

Shrnutí AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Zdrojový kód
original-source
//load bmp
int LoadBitmapFile(char* FileName, int x, int y, HWND hwnd)
{
BITMAP bm;
HDC hdc = GetDC(hwnd);
BitHandle = (HBITMAP)LoadImage(NULL, FileName, IMAGE_BITMAP, 0,0, LR_LOADFROMFILE);
if(BitHandle == NULL)
{
MessageBox(0, "Error loading the specified bitmap", "Program Error!",
MB_ICONERROR | MB_SYSTEMMODAL | MB_OK);
}
HDC dc = CreateCompatibleDC(hdc);
SelectObject(dc, BitHandle);
GetObject(BitHandle, sizeof(BITMAP), &bm);
BitBlt(hdc, x, y, bm.bmWidth, bm.bmHeight, dc, 0,0, SRCCOPY); 
ReleaseDC(hwnd, hdc);
return(0);
}
/* to load a bmp simple call the function as follows : LoadBitmapFile("bitmap.bmp",50,50,hwnd);
hope this helps */
Původní komentáře (3)
Obnoveno z Wayback Machine