Advertisement

Color key problem

Started by January 18, 2000 10:11 PM
0 comments, last by ECKILLER 25 years, 1 month ago
Hi, Hers''s my problem. I first blt my logo to the screen, which works fine, then i blit my background to the screen and begin animating. However my sprite''s background is being showed, the color keying isnt working. Here''s my code that you may need to help. void Animate_Images() { RECT rect; lpDDSBack->BltFast(0,0,dojo,NULL,DDBLTFAST_WAIT/DDBLTFAST_SRCCOLORKEY); rect.left = 0; rect.top = 0; rect.bottom = 200; rect.right = 200; // draw the current sprite cell lpDDSBack->BltFast(0,200,arr_anime[current_image],▭,DDBL TFAST_WAIT/DDBLTFAST_SRCCOLORKEY); lpDDSPrimary->Flip(0,DDFLIP_WAIT); current_image++; if(current_image >= IMAGE_COUNT) current_image = 0; Sleep(200); } void Set_Color_Key() { DDPIXELFORMAT ddpf; ddpf.dwSize = sizeof(ddpf); lpDDSPrimary->GetPixelFormat(&ddpf); // determine proper key for pixel format, green // KeyColor is global KeyColor = ddpf.dwGBitMask; // set color keys DDCOLORKEY key; key.dwColorSpaceHighValue = KeyColor; key.dwColorSpaceLowValue = KeyColor; for (int i = 0; i < IMAGE_COUNT; i++) arr_anime->SetColorKey(DDCKEY_SRCBLT, &key); dojo->SetColorKey(DDCKEY_SRCBLT, &key); } void Draw_Logo() { // draw my logo lpDDSBack->BltFast(0,0,logo,NULL,DDBLTFAST_WAIT); first_run = false; lpDDSPrimary->Flip(0,DDFLIP_WAIT); Sleep(2000); } ECKILLER ECKILLER
ECKILLER
I had this problem a while back, but I don''t remember what I was doing wrong. Instead of trying to figure it all out again, here is some code I use to display a mouse cursor. You should be able to use thins code to get yours to work.

// Define Our Cursor Surface Size
ddSurfaceDescription2.dwFlags = DDSD_CAPS / DDSD_WIDTH / DDSD_HEIGHT / DDSD_CKSRCBLT;
ddSurfaceDescription2.dwWidth = 25;
ddSurfaceDescription2.dwHeight = 30;
ddSurfaceDescription2.ddckCKSrcBlt.dwColorSpaceLowValue = 0;
ddSurfaceDescription2.ddckCKSrcBlt.dwColorSpaceHighValue = 0;

// Create Our Surface For Our Cursor
if (FAILED(g_lpDD7->CreateSurface(&ddSurfaceDescription2, &g_lpDDS7_Cursor, NULL)))
throw "Failed To Create Our Cursor Surface";

...

// Blit Our Cursor Using Source Color Keying (Black)
g_lpDDS7_Back->Blt(&rectDestination, g_lpDDS7_Cursor, &rectSource, DDBLT_WAIT / DDBLT_KEYSRC, NULL);

This code shows how I create the surface for the mouse and how I blit it to the screen.

Hope this helps.

This topic is closed to new replies.

Advertisement