1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
bool LoadAndBlitBitmap(string FileName, HDC hWinDC)
{
acImage::Image img;
int a = acImage::LoadTga("icon.tga", img);
if(a < 0)
MessageBox(NULL, "Error loading Hero Image!", NULL, MB_ICONERROR);
acImage::Image bmpTga;
acImage::ConvertToARGB(bmpTga, img);
HBITMAP bmp = CreateBitmap(bmpTga.width, bmpTga.height, 1, 32, bmpTga.data);
SetBitmapDimensionEx(bmp, 64, 64, NULL);
HDC hLocalDC;
hLocalDC = CreateCompatibleDC(hWinDC);
if (hLocalDC == NULL)
{
MessageBox(NULL, "CreateCompatibleDC Failed", "Error", MB_OK);
return false;
}
BITMAP qBitmap;
int iReturn = GetObject((HGDIOBJ)bmp, sizeof(BITMAP), (LPVOID)&qBitmap);
if (!iReturn)
{
MessageBox(NULL, "GetObject Failed", "Error", MB_OK);
return false;
}
HBITMAP hOldBmp = (HBITMAP)SelectObject(hLocalDC, bmp);
if (hOldBmp == NULL)
{
MessageBox(NULL, "SelectObject Failed", "Error", MB_OK);
return false;
}
BOOL qRetBlit = BitBlt(hWinDC, 210, 31, bmpTga.width, bmpTga.height, hLocalDC, 0, 0, SRCCOPY);
if (!qRetBlit)
{
MessageBox(NULL, "Blit Failed", "Error", MB_OK);
return false;
}
SelectObject(hLocalDC, hOldBmp);
DeleteDC(hLocalDC);
DeleteObject(bmp);
return true;
}
|