Skip to main content
gamedev.net
🔒 Locked

ColorKey Problem

Started by Amigo Jun 8, 2002 at 12:00 PM 0 replies 550+ views
Original Post
Amigo
Amigo
Hi, I am having some problems with Colorkeys. Iam running my game in 16 bit, the bitmaps are stored in 24 bit format. The bitmaps are loaded with the bitmap loading function which was posted here once by BigSassy. The function converts the bitmap to 16bit I believe. The problem is that the specified colorkey is just ignored, i dont know whats wrong ..... perhaps someone from this forum can help me ? thanks alot ! Heres the bitmap loading func : GPBITMAP Graphics::GPLoadBitmap(char* szBitmap) { GPBITMAP tempbitmap; LPDIRECTDRAWSURFACE4 bitSurface; BITMAPINFOHEADER infoheader; DDSURFACEDESC2 surfaceDesc; WORD *bitmapData; WORD *bitmapDone; FILE *bitmapFile; BYTE red, green, blue; int padding; bitmapFile = fopen(szBitmap, "rb"); fseek(bitmapFile, sizeof(BITMAPFILEHEADER), SEEK_SET); fread(&infoheader, sizeof(BITMAPINFOHEADER), 1, bitmapFile); // get the padding at the end of the bitmap padding = 4 - ((infoheader.biWidth * 3) % 4); if(padding == 4) padding = 0; ZeroMemory(&surfaceDesc, sizeof(surfaceDesc)); surfaceDesc.dwSize = sizeof(surfaceDesc); surfaceDesc.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH; surfaceDesc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; surfaceDesc.dwWidth = infoheader.biWidth; surfaceDesc.dwHeight = infoheader.biHeight; lpdd->CreateSurface(&surfaceDesc, &(bitSurface), NULL); ZeroMemory(&surfaceDesc, sizeof(surfaceDesc)); surfaceDesc.dwSize = sizeof(surfaceDesc); bitSurface->Lock(NULL, &surfaceDesc, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL); bitmapData = new WORD[infoheader.biWidth * infoheader.biHeight]; bitmapDone = (WORD *)surfaceDesc.lpSurface; for( int y=0; y=0; --y) { for( int x=0; xUnlock(NULL); tempbitmap.surface = bitSurface; tempbitmap.width = infoheader.biWidth; tempbitmap.heigth = infoheader.biHeight; fclose(bitmapFile); return(tempbitmap); } // end load Bitmap here iam trying to set the colorkey : COLORREF color_to_convert = srckey; DWORD transparent_key = DDColorMatch(lpddsback, color_to_convert); //Write_Error("transparent_key is %x\n", transparent_key); // set color key to default color DDCOLORKEY color_key; // used to set color color_key.dwColorSpaceLowValue = 0; color_key.dwColorSpaceHighValue = 0; // now set the color key for source blitting surface.surface->SetColorKey(DDCKEY_SRCBLT, &color_key); _amigo

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.