flipsflops
May 30th, 1999, 11:29 AM
Suggestions please. I can display a bitmap file from a preloaded resouce (using LoadBitmap) onto a window, but unable to do so when using an externally loaded file (using CreateBitmap).
[external file format decompression is okay - PCX format]
Jaeyeon Lee
May 30th, 1999, 08:46 PM
Check if the loaded file is a bitmap with palette(256 color image, for example).
In that case, you must realize the palette before you call BitBlt to display it correctly.
flipsflops
May 31st, 1999, 09:35 AM
The following is a preview of your post. If everything looks ok then you can click 'Continue' and your post will be entered. If not then use your back button to go back and edit some more.
Subject: Re: Displaying a Bitmap
I decode a PCX file, create & select the palette, but return a NULL when trying to realize it. I do not think this is the problem though.
The SelectObject function returns a NULL when tring to select the externally read in data, although the CreateBitmapIndirect & CreateCompatibleDC functions appear to work correctly and return handles.
The code below shows what I am doing, although what is wrong I cannot see ...
hpal = CreatePalette( &logpal );
oldhpal = SelectPalette( hdc, hpal, FALSE );
check = RealizePalette( hdc );
hbmpMyBitmap = CreateBitmapIndirect( &bm ); //hbmpMyBitmap = LoadBitmap(hInst, "MyBitmap"); //Using this internal resource, I display a bitmap in the window
//GetObject(hbmpMyBitmap, sizeof(BITMAP), &bm);
hdcMemory = CreateCompatibleDC(hdc);
hbmpOld = SelectObject(hdcMemory,
hbmpMyBitmap);i = BitBlt(hdc, 80, 80, bm.bmWidth, bm.bmHeight, hdcMemory, 0, 0, SRCCOPY);
SelectObject(hdcMemory, hbmpOld);
DeleteDC(hdcMemory);
ReleaseDC(hwnd, hdc);
any ideas please ?
flipsflops
May 31st, 1999, 11:21 AM
It would seem that the hardware caperbility changes with different resolutions, and the RC_PALETTE funtionality disappeared on my system when I changed from colour 256 mode.
When in colour 256 mode I have RC_PALETTE functionality and hence I can display a decoded PCX file as a bitmap on a window.
I used GetDeviceCaps(phdc, RASTERCAPS) & RC_PALETTE
to check for the RC_PALETTE flag.
Thats it !