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.

AppGameKit Classic Chat / Image has non transparent ring around it

Author
Message
Kobaltic
12
Years of Service
User Offline
Joined: 24th Jan 2012
Location: PA, USA
Posted: 25th Jan 2014 23:53
I made a tree. See the pic. I set the background to a pinkish color. I then use setImageTransparentColor to make the background transparent. However it doesn't fully remove the background from the image. Any thoughts on how to fix it? ( I thought someone else had this problem a few years back but I couldn't find anything.)

Attachments

Login to view attachments
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 26th Jan 2014 00:02
First off, this is an old method to do transparency. It's usually better to use a PNG file with transparency. If you want perfect transparency you can go with 32 bit files, if you only want 1/0 transparency you can use 8 bit files (like I do in RTA).

For this too work you need the transparent pixels to be exactly the specified color. If any of the pixels are blended colors they will not be transparent. I do not know what happens when filtering is added in AppGameKit, this could cause blended colors. If you have made the images correctly you can turn off filtering with SetDefaultMagfilter( 0 ) and SetDefaultMinfilter( 0 ).

Kobaltic
12
Years of Service
User Offline
Joined: 24th Jan 2012
Location: PA, USA
Posted: 26th Jan 2014 02:05
I have the same problem in Photoshop. I think you are right and there is a little color blending that is changing the color value.
David Gervais
Retired Moderator
19
Years of Service
User Offline
Joined: 28th Sep 2005
Location: Montreal, Canada
Posted: 26th Jan 2014 11:29 Edited at: 26th Jan 2014 11:30
Attached is a quick example of the effect you have going on..



When you stamp an image over a bright purple background and that original image has alpha channel transparency the tree image 'bleeds' into the purple background.. and as you ca see the results are close to what is happening in your game.

In my sample the middle image is the original.. the left is trying to match your conditions and the one on the right is a possible solution if you need to stick with the single color transparency.

What I did on the right is use a flat neutral gray R128,G128,B128 as the background and stamped the tree on it then set it as the transparency.. as you can see it's still not as good as the middle one, but it's a wee bit better than using the R255,G000,B255 as the transparent color..

the effect becomes even more apparent if the tree is placed on a dark or black background..

See next post to continue....

Attachments

Login to view attachments
David Gervais
Retired Moderator
19
Years of Service
User Offline
Joined: 28th Sep 2005
Location: Montreal, Canada
Posted: 26th Jan 2014 11:31 Edited at: 26th Jan 2014 11:34
Here as you can see it's way more obvious.. but the one on the right is still preferable to the one on the left..



If possible always try to use 32 bit .png with alpha channel transparency. it's the best solution. But as I have demonstrated, there are compromises that can be done.

If you go with a flat grey, you can make the grey a bit darker and have slightly better results if most of your game is darker backgrounds.. like R162 G162 B162

and here endith the lesson, I hope this helps.

Cheers!

Attachments

Login to view attachments
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 26th Jan 2014 12:29 Edited at: 26th Jan 2014 12:31
Yeah, 32 bit PNG if you are going for quality. 8 bit (256 color) PNG if you are going for a smaller file size. The advantage of 32 bit is that you get an alpha channel, making objects blend together and leave no sharp edges. 8 bit can use a transparent color, so you don't need to set any specific color for this. 8 bit PNGs also have custom pallets, so you don't have to sacrifice much quality. And Photoshop can export to both formats easily and they are supported by AppGameKit and all platforms. So really, no reason not to go PNG.

Kobaltic
12
Years of Service
User Offline
Joined: 24th Jan 2012
Location: PA, USA
Posted: 26th Jan 2014 22:07
Thanks for the help guys. I will look into the 32 bit pngs.
Kobaltic
12
Years of Service
User Offline
Joined: 24th Jan 2012
Location: PA, USA
Posted: 28th Jan 2014 02:40 Edited at: 28th Jan 2014 02:59
I had to get SuperPng to get the alpha to work. At least I know have a transparent alpha channel in the png. Thanks for the tips guys.

edit: I now have full control of the alpha channel and can do different levels of transparency just like I am used to with tgas. I was able to get rid of the ring around my tree. Thanks again
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 28th Jan 2014 09:38
In case you haven't figured it out yet: In Photoshop, make sure your art is separate from the background layer. Then turn off the background layer and save as PNG. Whatever is transparent in Photoshop will then be transparent in the image. 32 bit PNG is always pixel perfect quality, both colors and transparency.

Kobaltic
12
Years of Service
User Offline
Joined: 24th Jan 2012
Location: PA, USA
Posted: 28th Jan 2014 23:55
Thanks, It will help save on memory. My big problem was I was generating the tree in another program and could only export with the background so I had to bring it in with a color as opposed to being transparent.
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 29th Jan 2014 10:26
Ah, I see! You should check and see if there's an option in that program to export directly to PNG or PSD without the background.

Login to post a reply

Server time is: 2024-11-25 02:39:40
Your offset time is: 2024-11-25 02:39:40