Code:
BLENDFUNCTION AlphaUsage;
HDC HDCBitmap; // DC for bitmaps
unsigned char MountainsData[524288]; // The mountains background
LPVOID MountainsDataPointer;
BITMAPINFO MountainsMainInfo;
BITMAPINFOHEADER MountainsInfo;
LPBITMAPINFOHEADER MountainsInfoPointer;
HBITMAP MountainsBMPHandle;
struct SceneryData Mountains;
void InitializeDrawing()
{
HDCScreen = GetDC(hwnd); // set the screen buffer DC
HDCBack = CreateCompatibleDC(HDCScreen); // create a compatible DC, of which is to be used for drawing into the back buffer
HDCBitmap = CreateCompatibleDC(HDCScreen); // for AlphaBlend
MountainsMainInfo.bmiHeader = MountainsInfo;
MountainsBMPHandle = CreateDIBitmap(HDCScreen, &MountainsMainInfo.bmiHeader, CBM_INIT, MountainsData, &MountainsMainInfo, DIB_RGB_COLORS);
SelectObject(HDCBitmap, MountainsBMPHandle); // select the created bitmap
HBMPBack = CreateCompatibleBitmap(HDCScreen, 800, 600); // create compatible bitmap, used for drawing into, but not on screen
SelectObject(HDCBack, HBMPBack); // select the created bitmap
ImageHandle = DrawDibOpen(); // set the DrawDib DC handle
AlphaUsage.BlendOp = AC_SRC_OVER;
AlphaUsage.BlendFlags = 0;
AlphaUsage.SourceConstantAlpha = 255;
AlphaUsage.AlphaFormat = AC_SRC_ALPHA;
... // front and back buffer things
if (DebugTest[0] == 0)
{
DebugTest[0] = 1; // so this test is processed only once
DebugTest[1] = HDCBitmap; // nonzero
DebugTest[2] = MountainsBMPHandle; // nonzero
sprintf(DebugDetails, "The resulting values are:\n%d\n%d\n%d\n%d\n%d.", DebugTest[1], DebugTest[2], DebugTest[3], DebugTest[4], DebugTest[5]); // for debugging
MessageBox(hwnd, DebugDetails, "Debug Results", MB_OK);
}
}
void DrawScenery()
{
DrawDibDraw(ImageHandle, HDCBack, 0, 0, SkyBGInfo.biWidth, SkyBGInfo.biHeight, SkyBGInfoPointer, SkyBGDataPointer, 0, 0, SkyBGInfo.biWidth, SkyBGInfo.biHeight, 0);
DrawDibDraw(ImageHandle, HDCBack, 0, 240, FogInfo.biWidth, FogInfo.biHeight, FogInfoPointer, FogDataPointer, 0, 0, FogInfo.biWidth, FogInfo.biHeight, 0);
// DrawDibDraw(ImageHandle, HDCBack, Mountains.XMain, Mountains.YMain, MountainsInfo.biWidth, MountainsInfo.biHeight, MountainsInfoPointer, MountainsDataPointer, 0, 0, MountainsInfo.biWidth, MountainsInfo.biHeight, 0);
// BitBlt(HDCBack, Mountains.XMain, Mountains.YMain, MountainsInfo.biWidth, MountainsInfo.biHeight, HDCScreen, MountainsInfo.biWidth, MountainsInfo.biHeight, SRCCOPY);
// AlphaBlend(HDCBack, Mountains.XMain, Mountains.YMain, MountainsInfo.biWidth, MountainsInfo.biHeight, HDCScreen, 0, 0, MountainsInfo.biWidth, MountainsInfo.biHeight, AlphaUsage);
DebugTest[3] = AlphaBlend(HDCBack, Mountains.XMain, Mountains.YMain, MountainsInfo.biWidth, MountainsInfo.biHeight, HDCBitmap, 0, 0, MountainsInfo.biWidth, MountainsInfo.biHeight, AlphaUsage);
// AlphaBlend(HDCBack, 4, 112, 1024, 128, HDCScreen, 0, 0, 1024, 128, AlphaUsage);
DrawDibDraw(ImageHandle, HDCBack, Logo.XMain, Logo.YMain, LogoInfo.biWidth, LogoInfo.biHeight, LogoInfoPointer, LogoDataPointer, 0, 0, LogoInfo.biWidth, LogoInfo.biHeight, 0);
DrawDibDraw(ImageHandle, HDCBack, 640, 0, RightSidePanelInfo.biWidth, RightSidePanelInfo.biHeight, RightSidePanelInfoPointer, RightSidePanelDataPointer, 0, 0, RightSidePanelInfo.biWidth, RightSidePanelInfo.biHeight, 0);
DrawDibDraw(ImageHandle, HDCBack, 0, 480, BottomSidePanelInfo.biWidth, BottomSidePanelInfo.biHeight, BottomSidePanelInfoPointer, BottomSidePanelDataPointer, 0, 0, BottomSidePanelInfo.biWidth, BottomSidePanelInfo.biHeight, 0);
BitBlt(HDCScreen, 0, 0, WindowSizeBase.x, WindowSizeBase.y, HDCBack, 0, 0, SRCCOPY); // swaps the back and front buffers for displaying
/*
if (DebugTest[0] == 0)
{
DebugTest[0] = 1; // so this test is processed only once
DebugTest[5] = GetLastError(); // shows 87 as the error code
sprintf(DebugDetails, "The resulting values are:\n%d\n%d\n%d\n%d\n%d.", DebugTest[1], DebugTest[2], DebugTest[3], DebugTest[4], DebugTest[5]); // for debugging
MessageBox(hwnd, DebugDetails, "Debug Results", MB_OK);
}
*/
}
This is all that changed, and their relative positions. For the debug test things, test 1 and test 2 both show a nonzero value. Test 3 shows 0 indicating failure. Test 4 is unused and test 5 shows 87. What parameter is invalid?