To bitmap or not to bitmap

Started by
5 comments, last by Fender148 23 years, 8 months ago
Ive been trying to get my bitmap on the screen for quite some time. To show me how Ive relied on LaMothe''s "Tricks of the Windows Game Programming Gurus", but because of one of us it has been to no avail. Ive been using his code and tried to follow his examples but I cant get it to work so Ive come here to ask for some advice. I can get my bitmap on the screen using ddutil.cpp, which I found out how to use in an article on this site, but in the book he says these functions are slow since theyre windows functions. Should I try writing my own stuff with the book as guidance, which Ive avoided doing due to my undying trust in things written by pros, does someone know of way to get the stuff to work, or should I do something else? Ive read about other complaints involving his source code, but I already got a replacement cd that had no changes. Thanks for reading, Im just venting my anger
Advertisement
hey,
I know for sure that his bitmap loading function will work. Make sure your bitmap''s dimensions are powers of two. Ex 64x64,
32x32....etc. You will have to change some things to get his code to work with other dimensions.

hope that helps,
skitzo_smurf
"Innocent is just a nice way to say ignorant, and stupidity is ignorance with its clothes off."words of,skitzo_smurf
Hey skitzo, thanks for replying. Ive been trying for a while and I just cant get it, I load the bitmap, but I cant get it on the back buffer, could you help me out a little? Thanks
Its a 32 x 32 bitmap, I made it with Paint Shop Pro, it works fine with ddutil functions
i''ll email you some code. I would post it here, but I dont wanna pollute the board with a super long reply.

check your mail,
skitzo_smurf
"Innocent is just a nice way to say ignorant, and stupidity is ignorance with its clothes off."words of,skitzo_smurf
I have also experienced that in LaMothe''s "Tricks of the Windows Game Programming Gurus" book, that his code that goes along w/the bitmap section cannot read bitmaps in of odd number width''s. If you use a bitmap w/certain width deminsions, the program will crash. if you use others it works fine. I have began to write my own BMP loader which (theroreticlly) should be better. I would suggested the same thing.

Hope this helped somehow

l8rz
Or if you''re lazy (like me ) you can have Windows do the job for you, with the assumption your using Windows of course.

    bool CSurface::LoadBitmap(const char* szfilename, IDirectDrawSurface7* lpdds){	bool b_reload = (lpdds) ? true:false;	BITMAPINFO* lpbi;	void* lpbits;	cifstream inp;	BITMAPFILEHEADER bmfh;		if(inp.open(szfilename)) return true;	inp.read(&bmfh, sizeof(BITMAPFILEHEADER));	if(bmfh.bfType != BITMAP_ID)	{		return true;	}	lpbi = (BITMAPINFO*)(new char[bmfh.bfOffBits - sizeof(BITMAPFILEHEADER)]);	inp.read(lpbi, bmfh.bfOffBits - sizeof(BITMAPFILEHEADER));	lpbits = (void*)(new char[bmfh.bfSize - bmfh.bfOffBits]);	inp.read(lpbits, bmfh.bfSize - bmfh.bfOffBits);	if(!b_reload) // CreateSurface here...	else if(lpbi->bmiHeader.biHeight != (signed)req_h || lpbi->bmiHeader.biWidth != (signed)req_w) { Release(); CreateSurface(lpbi->bmiHeader.biWidth, lpbi->bmiHeader.biHeight, texture); }	HDC hdc;	lpdds->GetDC(&hdc);	StretchDIBits(hdc, 0, 0, lpbi->bmiHeader.biWidth, lpbi->bmiHeader.biHeight, 0, 0, lpbi->bmiHeader.biWidth, lpbi->bmiHeader.biHeight, lpbits, lpbi, DIB_RGB_COLORS, SRCCOPY);	lpdds->ReleaseDC(hdc);	delete[] lpbi;	delete[] lpbits;	inp.close();	return false;    


"Paranoia is the belief in a hidden order behind the visible." - Anonymous

This topic is closed to new replies.

Advertisement