can any1 tell why this Blt won't do transparent?
I have a program that is try to use transparent blitting but it is still displaying the entire rectangular tile and not the diamond-shaped that should be left... I NEED to use a range of 253-255 for the colorkey.
this is where I load my bitmap of tiles and make a surface from it:
// create a DirectDrawSurface for this bitmap
ZeroMemory(&ddsd, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS / DDSD_HEIGHT /DDSD_WIDTH / DDSD_CKSRCBLT;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
ddsd.dwWidth = bm.bmWidth;
ddsd.dwHeight = bm.bmHeight;
if (pdd->CreateSurface(&ddsd, &pdds, NULL) != DD_OK)
return NULL;
here is the code that does the blit:
DDCOLORKEY ckey;
ckey.dwColorSpaceLowValue = 253;
ckey.dwColorSpaceHighValue = 255;
lpDDSTiles->SetColorKey(DDCKEY_COLORSPACE / DDCKEY_SRCBLT, &ckey);
lpDDSPrimary->Blt( &rr, lpDDSTiles, &rcFrame,
DDBLT_WAIT / DDBLT_KEYSRC, NULL ) );
Thanks in advance!
Allyn
Most video hardware does not support colour key ranges Colour key ranges are mostly for techniques like bluescreening, see your DirectX documentation for details. You''ll have to restrict yourself to one colour for your colour key.
Dale Freya
Programming Instructor of Diploma of Information Technology (Software Development) GAMES
QANTM Cooperative Multimedia Centre
Dale Freya
Programming Instructor of Diploma of Information Technology (Software Development) GAMES
QANTM Cooperative Multimedia Centre
Dale FreyaAmaranth - Software Engineering ManagerInstructor - Vocational Education Computer Games & Interactive Entertainment
Empyrean is on track. Sorry.
"Remember, I'm the monkey, and you're the cheese grater. So no fooling around."
-Grand Theft Auto, London
"Remember, I'm the monkey, and you're the cheese grater. So no fooling around."
-Grand Theft Auto, London
D:
Are you using a 8-bit display mode? Because if you aren't, the values 253 and 255 don't make much sense. Otherwise, e.g., in a 16-bit 565 RGB mode all values 253-255 would be reduced to an all ones sequence of length 5 or 6 bits. So if you are using a 16-bit mode, you'll get rid of the problem easily in this case with a few corrections. If you need help with these, post here.
Also, I think you have to do this:
ckey.dwSize = sizeof(ckey);
Edited by - Gefilus on 3/3/00 3:47:48 AM
Also, I think you have to do this:
ckey.dwSize = sizeof(ckey);
Edited by - Gefilus on 3/3/00 3:47:48 AM
Curiously enough, the return value when I do the SetDisplayMode(640,480,8) is DD_OK, so it should be in palettized mode...
if (!DD_OK == lpDD->SetDisplayMode(640,480,8)) {
fprintf(debugfile,"Failed to set 640,480,8 mode\n");
}
else fprintf(debugfile,"Display set to 640x480x8\n");
DDSURFACEDESC lpDDdesc;
if (!DD_OK == lpDD->GetDisplayMode(&lpDDdesc) ) {
fprintf(debugfile,"GetDisplayMode failed\n");
}
else fprintf(debugfile,"h=%ld, w=%ld\n", lpDDdesc.dwHeight,lpDDdesc.dwWidth);
This is the result of debugfile:
Display set to 640x480x8
h=0, w=52822016
I don''t understand the values put into lpDDdesc...
if (!DD_OK == lpDD->SetDisplayMode(640,480,8)) {
fprintf(debugfile,"Failed to set 640,480,8 mode\n");
}
else fprintf(debugfile,"Display set to 640x480x8\n");
DDSURFACEDESC lpDDdesc;
if (!DD_OK == lpDD->GetDisplayMode(&lpDDdesc) ) {
fprintf(debugfile,"GetDisplayMode failed\n");
}
else fprintf(debugfile,"h=%ld, w=%ld\n", lpDDdesc.dwHeight,lpDDdesc.dwWidth);
This is the result of debugfile:
Display set to 640x480x8
h=0, w=52822016
I don''t understand the values put into lpDDdesc...
Try removing the DDCKEY_COLORSPACE flag from your call to SetColorKey. If you are setting palette numbers in an 8bpp surface, then that flag is probably what''s screwing you up.
I checked the dx7sdk help file and found the following:
8-bit palettized mode
// Palette entry 26 is the color key.
dwColorSpaceLowValue = 26;
dwColorSpaceHighValue = 26;
16-bit color mode
// Color is bright purple
dwColorSpaceLowValue = 0xf81F;
dwColorSpaceHighValue = 0xf81F;
as you can see from this if you are using 8bpp then both the high and low values must be the same.
Hope that helps.
8-bit palettized mode
// Palette entry 26 is the color key.
dwColorSpaceLowValue = 26;
dwColorSpaceHighValue = 26;
16-bit color mode
// Color is bright purple
dwColorSpaceLowValue = 0xf81F;
dwColorSpaceHighValue = 0xf81F;
as you can see from this if you are using 8bpp then both the high and low values must be the same.
Hope that helps.
[email=wytraven@kik.net]wytraven@kik.net[/email]There is nothing real outside our perception of reality. Is there?
Not necesarily, they can be different but the high value should be higher than the low value. This allows for transparency like Team colors, etc.
Cloxs is right, but the HEL doesn''t support colour ranges, ddraw relies on hardware only for that which can be checked for using DDSCAPS:
Quote
Support for a range of colors rather than a single color is hardware-dependent. Check the dwCKeyCaps member of the DDCAPS structure for the hardware. The HEL does not support color ranges.
End Quote
Quote
Support for a range of colors rather than a single color is hardware-dependent. Check the dwCKeyCaps member of the DDCAPS structure for the hardware. The HEL does not support color ranges.
End Quote
[email=wytraven@kik.net]wytraven@kik.net[/email]There is nothing real outside our perception of reality. Is there?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement