Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Transparency problem with sprites

Author
Message
Orac
18
Years of Service
User Offline
Joined: 16th May 2006
Location: Billingham
Posted: 12th Mar 2008 00:26
Hi all,

I've been playing around with DarkGDK and VS2008 and hit a problem, I don't know if it's a bug or I'm doing something wrong.

I set the colour key to red using dbSetImageColorKey(255,0,0) and if I load an image with dbLoadImage(),assign it to a sprite with dbSetSpriteImage() and display it with dbSprite(), the transparency works as expected.

But if I create an image from a memblock (I used the code posted by IanM some time ago), then display it, the transparency doesn't work i.e. I can see the red colour around the image.

Any ideas?
Flashing Blade
21
Years of Service
User Offline
Joined: 19th Oct 2002
Location: United Kingdom
Posted: 12th Mar 2008 16:02
Where are you getting your memblock data from? Are you using dbGetImage()? If so don't forget the extra 1 to grab image without anti-aliasing.

Also, if making a image from memblocks why not use the alpha channel?


The word "Gullible" cannot be found in any English Dictionary.
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 13th Mar 2008 05:32
Quote: "The word "Gullible" cannot be found in any English Dictionary."
You're RIGHT! But I found a book called Gullible's Travels... I'm going to make a MMORPG based on it

Seriously, Flashing Blade is correct. I did that BitMap Font (Newletter 59 I tink) and went through it fowards, backwards, and that part wasn't so bad - but getting into the Image format, dealing with RGB and the Alpha... Paid off!

You can do some neat things just loading images with an Alpha Channel, but its prety fun to play with them programmatically to.

You should check out the MakeImageFromMemblock thing and MakeMemblockFrom Image.....

format for memblock made this way is:

First Four Bytes (DWORD, Offset 0) : Image Width
Next Four Bytes (DWORD, Offset 4) : Image Height
Next Four Bytes (DWORD, Offset 8) : Image Depth (usually 32)
from there, its a grid of DWORD, therefore each pixel is 4 bytes..

PixelOffset = 12 + ((x + ( Y * Width))*4)

To Get Individual "channels", using that PixelOffset Value:

dbWriteMemblockByte(MemID, PixelOffset+0, Blue);
dbWriteMemblockByte(MemID, PixelOffset+1, Green);
dbWriteMemblockByte(MemID, PixelOffset+2, Red);
dbWriteMemblockByte(MemID, PixelOffset+3, Alpha);

Good Luck!

Orac
18
Years of Service
User Offline
Joined: 16th May 2006
Location: Billingham
Posted: 13th Mar 2008 10:19
Thanks for input guys.

@Flashing Blade - I'm loading the data from a resource that was compiled into the exe, I'm not sure how to load an alpha channel separately, but I'll google about for it.

@jason p sage - I used those functions to make the image, and it worked OK, it's just the transparency thing.

Login to post a reply

Server time is: 2024-09-29 15:23:36
Your offset time is: 2024-09-29 15:23:36