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 / Color problem with dbLoadImage / dbSprite

Author
Message
DavidD
18
Years of Service
User Offline
Joined: 6th May 2006
Location:
Posted: 22nd Aug 2010 06:49
Hello,
I'm hoping someone has experienced this before and can point me in the right direction. I've painted a space image and am trying to load it as a background in Dark GDK. The image loads and displays as a sprite (will be moved around), however, it seems that at least one of the colors has been replaced with blue. (Image excerpt attached)

The picture loads fine in any paint program or viewer. Also, if I replace this picture in my program with any other photo, it displays fine.

Attachments

Login to view attachments
Jeff032
17
Years of Service
User Offline
Joined: 13th Aug 2007
Location:
Posted: 23rd Aug 2010 03:58
Try setting the colorkey before you load the image to a color you aren't using (such as magenta). I think the command would be dbSetImageColorkey or something similar. I believe the default is black = transparent.

Alternatively, I believe if you save your background as a png, that should fix it as well.

(I would go for converting it to png, it would probably be a smaller file anyway)

Cuddle Bunniezzz 12
15
Years of Service
User Offline
Joined: 14th Jan 2009
Location: Buffalo, NY
Posted: 23rd Aug 2010 04:35 Edited at: 23rd Aug 2010 04:35
Might I ask, in your original image, (the now blue), did it used to be black, with and RGB value of 0, 0, 0? If so, here is a little explination.

When you load images that don't have an alpha channel (transparency) built into them, DarkGDK treats one color as something known as a color key.

What happens is that this color key (the default is RGB 0, 0, 0, a.k.a pure black) then becomes transparent when loading images.

This is because in the older days of creating games, they understood the concept of transparency, but the images they had didn't have an alpha channel. So game creator designated a certain RGB value to become the transparent color (a common one was RGB (255, 0, 255) a.k.a. pink).

But now because of new and better file formats, they have built in alpha channel support (like PNG, seriously, try it).

And you may ask "Why is that blue appearing in there?" Well, you see, DarkGDK loads all images into the 3D plain, and in DirectX (I think it is DirectX, if not, someone please correct me), by default, the background color is blue.

Of course, you can change this and get it black if you want.

All you need need to do is add this code to your game loop:


You might also want to get rid of that "dbDisableEscapeKey()", and that if statement in the game loop.

http://ref.darkgdk.us/ <- Online DarkGDK Refernece. More content coming soon.
DavidD
18
Years of Service
User Offline
Joined: 6th May 2006
Location:
Posted: 23rd Aug 2010 05:57
Thank you very much for the responses. They were very helpful. I thought the same, and did try to add a color key of bright pink, but the image still loaded the same way. However, after loading the picture up in a paint program, and changing all of the 0,0,0 values to a different shade, it loaded just fine. Maybe I used the colorkey incorrectly, I'll take another look.

Thanks for taking the time to give such helpful/generous answers

Dave
3d point in space
15
Years of Service
User Offline
Joined: 30th Jun 2009
Location: Idaho
Posted: 23rd Aug 2010 23:54
If you color is brownish.

I mess with bitmaps all the time sometimes. I get bgr in that order instead of rgb if I use memblocks. So if you are useing a memblock try and put blue first. Sounds kinda stupid but I acually thought that I was recieving no blue on my images also tell i fliped red with blue.

If this is not the case post a picture of the display.

vent:
lead.typefrag.com
16020

Go through yourself at a wall.
Cuddle Bunniezzz 12
15
Years of Service
User Offline
Joined: 14th Jan 2009
Location: Buffalo, NY
Posted: 26th Aug 2010 02:10
@DavidD,

Remember that the color key you set in your code (ex. "dbSetImageColorKey(255, 0, 255);"), has to match up EXACTLY with the colors in your image.

But this method is a bit old and outdated. Nowadays we use .png with transparency.

Best free PNG editor:
http://www.getpaint.net/

(It's magical, though I'm forced to use an older version because I can't update to XP SP3, which intern I can't update Paint.NET. Still great software!)

http://ref.darkgdk.us/ <- Online DarkGDK Refernece. More content coming soon.

Login to post a reply

Server time is: 2024-11-19 18:43:59
Your offset time is: 2024-11-19 18:43:59