Displaying Hi Colour Bitmaps
Hi all,
I have been working through ''Tricks of a Windows Game Programming Guru'' for a while, but I am having a problem displaying bitmaps.
I can display 8-bit bitmaps with no problem, but I really want to use hi colour images in my games, but I can''t get the pictures to display, infact not even the 16 bit apps on the supplied CD (that came with the book) work.
The image loads into the bitmap object and the program compiles and executes fine, but all I get is a black screen. Another thing is if I output text to the back buffer (where the background picture should have been copied to, the text is displayed.
If anyone can give ANY help i''d appreciate a reply,
Cheers
Wizzard
Maybe your video board is so old that it handles only 256 palettized colors
OK, let''s be serious now. Are you sure that the bitmap file(s) you want to load and display are in the SAME directory as the executable where they should be ?
I hope this helps.
OK, let''s be serious now. Are you sure that the bitmap file(s) you want to load and display are in the SAME directory as the executable where they should be ?
I hope this helps.
I really got my hopes up when I saw I had a reply,
then you said my graphics card was crap and I was probably thick cos I have my file in a different directory! You may as well said I had a semi colon missing or something!
(I am just joking incase you think I''m serious)
Ta for the reply,
BUT
1) I have a geForce2 and
2) bitmap is in the root directory of the project, which is where the code is looking.
It''s getting me REALLY miffed cos it SHOULD work! (he says whilst ripping his hair out).
Outputting the info about the bitmap (size, bbp etc) shows the file is loaded into memory, it just won''t put it on the screen.
Do I have to do anything special to it to put it on the screen that I wouldn''t have to do to a 256 colour bitmap?
WizzardUK
then you said my graphics card was crap and I was probably thick cos I have my file in a different directory! You may as well said I had a semi colon missing or something!
(I am just joking incase you think I''m serious)
Ta for the reply,
BUT
1) I have a geForce2 and
2) bitmap is in the root directory of the project, which is where the code is looking.
It''s getting me REALLY miffed cos it SHOULD work! (he says whilst ripping his hair out).
Outputting the info about the bitmap (size, bbp etc) shows the file is loaded into memory, it just won''t put it on the screen.
Do I have to do anything special to it to put it on the screen that I wouldn''t have to do to a 256 colour bitmap?
WizzardUK
March 14, 2002 09:09 AM
It would help if we knew what compiler/OS/API''s you''re using.
Billy - BillyB@mrsnj.com
Billy - BillyB@mrsnj.com
I am using Visual C++ 6 running on Windows XP Pro.
The DirectX 8 SDK is installed, but I am only using
LPDIRECTDRAW4, so whats that DIrectX 6?
The DirectX 8 SDK is installed, but I am only using
LPDIRECTDRAW4, so whats that DIrectX 6?
The older detonator drivers had big problems with XP, Perhaps thats your problem.
,Jay
,Jay
Well thats how I load 24bit Bitmaps:
Maybe this helps
struct CfBitmap{ unsigned int sizeX, sizeY; unsigned int size; unsigned int bpp; void* pPixels;public: CfBitmap():pPixels(NULL) {} void Release();};class CfBmpLoader {public: CfBitmap* LoadBitmapFromFile(char* _filename); CfBitmap* LoadBitmapFromStream(void* _stream, unsigned int _size); CfBmpLoader(); virtual ~CfBmpLoader();protected: BITMAPFILEHEADER BmpHeader; BITMAPINFOHEADER BmpInfoHeader; BITMAPCOREHEADER BmpCoreHeader;};CfBitmap* CfBmpLoader::LoadBitmapFromFile(char *_filename){ //create new Bitmap CfBitmap* pBmp= new CfBitmap; memset(&BmpHeader, 0, sizeof(BmpHeader)); memset(&BmpInfoHeader, 0, sizeof(BmpInfoHeader)); memset(&BmpCoreHeader, 0, sizeof(BmpCoreHeader)); //open file FILE* f= fopen(_filename, "r"); if(NULL==f) return NULL; //Read Header fread(&BmpHeader, sizeof(BmpHeader), 1, f); //Read InfoHeader fread(&BmpInfoHeader, sizeof(BmpInfoHeader), 1, f); pBmp->bpp=BmpInfoHeader.biBitCount; pBmp->sizeX=BmpInfoHeader.biWidth; pBmp->sizeY=BmpInfoHeader.biHeight; pBmp->size=pBmp->sizeX*pBmp->sizeY*(pBmp->bpp/8); pBmp->pPixels= new char[pBmp->size]; fread((unsigned char*)pBmp->pPixels, pBmp->size, 1, f); return pBmp;}
Maybe this helps
I have just checked ndivia''s website and I have the latest drivers 23.11.
If anyone can send me some code they have that works with 16 bit images I would appreciate it.
If the program just displays a 16 bit image in the background and nothing else I could compare it with mine and see whats different.
I have read elsewhere that I shouldn''t be using LaMothe''s Bitmap functions as they arn''t too good, but I should be using windows bitmap function instead. Whats everyone else using?
Would it make a difference if I save the images as a resource instead of loading it from disk?
Cheers again for the replies
Wizzard
wizzarduk@hotmail.com
If anyone can send me some code they have that works with 16 bit images I would appreciate it.
If the program just displays a 16 bit image in the background and nothing else I could compare it with mine and see whats different.
I have read elsewhere that I shouldn''t be using LaMothe''s Bitmap functions as they arn''t too good, but I should be using windows bitmap function instead. Whats everyone else using?
Would it make a difference if I save the images as a resource instead of loading it from disk?
Cheers again for the replies
Wizzard
wizzarduk@hotmail.com
The CDROM included with Twgpg includes the source codes, bitmaps AND compiled binaries of the source. Does it works when you run the precompiled binaries ?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement