|
From: Elias P. <eli...@ao...> - 2001-06-25 19:06:10
|
> I fear that won't help cause I don't want to _set_ the parameter I wanna _get_
> these informations of the DIB.
Yes, I looked at the documentation now, and that function already needs some
info. You could always use GetObject() to get the bitmap dimensions.
> How to load a Image from disk, let's say "picture.bmp" (which is -just for
> example- about 50k),
> findout its dimensions and display it on the screen?
Ok, if that is all you want to do, there's no need for DIBitmaps at all..
I paste some example code which loads and displays a bitmap directly on the
desktop.
Elias Pschernig
--
#include <windows.h>
int WINAPI WinMain(HINSTANCE hinst,HINSTANCE prev,LPSTR arg,int show) {
HANDLE bitmapHandle;
HDC sourceDC, destinationDC;
BITMAP bitmap;
// load bitmap from disk
bitmapHandle = LoadImage(NULL, "test.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
// normally, you will use: destinationDC = GetDC(hWnd); hWnd being the window to
// draw to, never use the desktop for that, for obvious reasons
destinationDC = GetWindowDC(GetDesktopWindow());
// Get data from the handle
GetObject(bitmapHandle, sizeof(bitmap), &bitmap);
// Create compatible device context and tell it to use the bitmap
sourceDC = CreateCompatibleDC(destinationDC);
SelectObject(sourceDC, bitmapHandle);
// draw the bitmap
BitBlt(destinationDC, 0, 0, bitmap.bmWidth, bitmap.bmHeight, sourceDC, 0, 0, SRCCOPY);
// In C, always release stuff you have allocated..
DeleteDC(sourceDC);
ReleaseDC(GetDesktopWindow(), destinationDC);
return 0;
}
|