got class?

Started by
9 comments, last by drarem 21 years, 11 months ago
Alright thanks I'll remember that. I suppose I could set the bitmaps up as a linked-list and when done, go thru and release/delete all - creating a destructor function for the class and throwing it in there.

Here is some sample source and the class so far, if anyone has a use for it. It seems to function well so far, if you need a quick bitmap or more loaded in on the fly..

************************************************
switch (message) /* handle the messages */
{
case WM_CREATE:
int i;
char buff[256];
RECT rc;
HDC hdc;
HDC MemDC;
BITMAP bm;
HBITMAP hBmp;
PAINTSTRUCT ps;
hBmpCls castlebck;
hBmpCls test;
hdc = GetDC(hwnd);
break;
case WM_PAINT:
hdc = GetDC(hwnd);
castlebck.InitBMP(MemDC, bm, hwnd, hdc, hBmp, "castle.bmp");
test.InitBMP(MemDC, bm, hwnd, hdc, hBmp, "test.bmp");
BeginPaint(hwnd, &ps);
MainLoop(hwnd, hdc, &test);
test.BMPStretch(0,0,800,600,0,0);
castlebck.BMPBlt(16,16,64,64,0,0);
EndPaint(hwnd, &ps);
break;
case WM_DESTROY:

***************************************************



//hBmpCls.h

class hBmpCls {
private:
HDC hMemDC;
BITMAP bm;
HWND hwnd;
HDC hdc;
HBITMAP hBmp;
char fname[255];
public:
int InitBMP(HDC, BITMAP, HWND, HDC, HBITMAP, char *);
int BMPStretch(int, int, int, int, int, int);
int BMPBlt(int, int, int, int, int, int);
};

int hBmpCls::InitBMP(HDC HMemDC, BITMAP Bm, HWND Hwnd, HDC Hdc, HBITMAP HBmp, char *Fname) {
RECT rc;
hMemDC = HMemDC;
bm = Bm;
hwnd = Hwnd;
hdc = Hdc;
hBmp = HBmp;
strcpy(fname, Fname);
GetClientRect(hwnd, &rc);
hMemDC = CreateCompatibleDC(hdc);
hBmp = (HBITMAP) LoadImage( NULL, Fname, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
CreateCompatibleBitmap(hMemDC, rc.right, rc.bottom);
GetObject(hBmp, sizeof(BITMAP), &bm);
SelectObject(hMemDC,hBmp);
return 0;
}

int hBmpCls::BMPStretch(int x1, int y1, int x2, int y2, int xc, int yc) {
StretchBlt(hdc,x1,y1,x2,y2,hMemDC,xc,yc,
bm.bmWidth,bm.bmHeight,SRCCOPY);
}

int hBmpCls::BMPBlt(int x1, int y1, int x2, int y2, int xc, int yc) {
BitBlt(hdc, x1, y1, x2, y2, hMemDC, xc, yc, SRCCOPY);
}






I fseek, therefore I fam.

[edited by - drarem on May 7, 2002 5:47:33 PM]
I'll give you a beating like Rodney King who deserved it!=====================================Any and all ideas, theories, and text c2004,c2009 BrainDead Software. All Rights Reserved.

This topic is closed to new replies.

Advertisement