RE: [Dev-C++] displaying images during runtime
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Ramana K. <xr...@ho...> - 2001-06-26 06:41:19
|
Following code works for me, dont think I included any important headers
<hInst> = the Instance of your program you can use a pointer to get this
from your main() function
<name> = is a char array containing the name in the resource of your picture
e.g:
MYPICTURE BITMAP C:/pic.bmp
//this is the code, it is part of a class function def, sorry, I just copied
out of my prog:
HBITMAP itsPicture;
ItsPicture = LoadBitmap(<hInst>,<name>);
void Room::Draw(HDC hdcWindow) const // just a function in my class
{
HDC hdcMemory;
hdcMemory = CreateCompatibleDC(hdcWindow);
RECT rc; //create a rectangle
rc.left = 0; //filled with black
rc.top = 0; //to act as a mask
rc.right = bm.bmWidth;
rc.bottom = bm.bmHeight;
FillRect(hdcWindow, &rc, (HBRUSH)GetStockObject((BLACK_BRUSH)));
SelectObject(hdcMemory, itsPicture);
BitBlt(hdcWindow, 0, 0, bm.bmWidth, bm.bmHeight, hdcMemory, 0, 0, SRCPAINT);
DeleteDC(hdcMemory);
}
Ramana
-----Original Message-----
From: dev...@li...
[mailto:dev...@li...]On Behalf Of Gregor Peter
Sent: Sunday, 24 June 2001 6:36 AM
To: dev cpp
Subject: [Dev-C++] displaying images during runtime
Hi there,
I like to display several images during runtime of my programm.
Charles Petzold uses in his book "Programming Windows" a function called
BITMAPFILEHEADER* DibLoadImage( szName filename )
from DIBFILE.H to manage this.
#include "dibfile.h"
BITMAPFILEHEADER* pbmfh;
pbmfh = DibLoadImage( "myFile.bmp" );
...
SetDIBitsToDevice( pbmfh.cx, pbmfh.cy, ... );
DevC++ doesn't know anything about the header-file and it's functions :-(
PS:
LoadImage( ) won't work cause it returns a HANDLE instead of a
BITMAPFILEHEADER.
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
|