HBITMAP hBmp; // A bitmap handle
BITMAP bmp; // A bitmap structure
HDC hSourceDC; // The source device context
extern HDC hDC; // Our window's device context
// Load the image into the bitmap handle
// This is the line that fails
if ( (hBmp = (HBITMAP)LoadImage(hInstance, cFilePath, IMAGE_BITMAP,
0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION)) == NULL)
{
LogErrorMsg("Unable to load image into DIB section");
LogInfo(cFilePath);
return (1);
}
// Make the source DC represent the whole screen
if (!(hSourceDC = CreateCompatibleDC(NULL)))
return (1);
// Blit the bitmap to screen
// Code omitted
// Now comes the housekeeping, we must free all memory
// Deletes the bitmap handle
if (!(DeleteObject(hBmp)))
return (1);
// Releases our device context from the main window
if (FAILED(lpddSurface->ReleaseDC (hDC)))
return (1);
// Deletes the source DC as we do not need it anymore
if (!(DeleteDC(hSourceDC)))
return (1);
Bitmap Loading - Incorrect parameter error
The following bitmap loading code generates an error message - "The parameter is incorrect" - at the line
...hBmp = LoadImage(...)..
when I use the GetLastError() function.
The thing is that for a while bitmaps are able to be loaded without any problem, but when I am loading my map, at around the 400th tile (the exact position is random), the code fails.
All non-local variables are passed by reference.
I'm making the program on Win2K and testing it on Win98SE, and it uses DirectX for loading the bitmaps. While the program works outside the IDE fine in Win2k, it's on 98SE that the problem lies.
Memory management is what strikes me, as the position of failure is quite random. But, I can't see anything wrong here. Any help is greatly appreciated.
I've omitted some code in the middle (BitBlt call etc.)
[edited by - DarkAvenger on April 11, 2002 9:51:28 PM]
[edited by - DarkAvenger on April 11, 2002 9:52:32 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement