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.

Newcomers AppGameKit Corner / gif file with black and transparency

Author
Message
Dale Schultz
2
Years of Service
User Offline
Joined: 1st Nov 2021
Location: Maine, USA
Posted: 20th Nov 2021 15:50
I have gif files with a transparent background.
Part of the image has black pixels (not transparent alpha = 255).

I cant get it to display in a sprite properly despite varying all modes of SetSpriteTransparency()
I am placing the sprite on a background sprite that is dark green

It seems that AppGameKit wants to treat black pixels as transparent, no matter what their alpha value is.

Setting the transparency with SetImageTransparentColor() does make a difference but since it takes no alpha parameter, I cant use it to differentiate between 0,0,0,255 and 0,0,0,0. In other words and I can make green be transparent, but I need to keep black as black and transparent black transparent.

Here are the results:
SetSpriteTransparency() mode 0 and 1


SetSpriteTransparency() mode 2


and the gif file


Am I gong to have to edit my gif files and change the black to slightly not black or the transparent pixels to not black with alpha zero? Seems weird!

Attachments

Login to view attachments
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 22nd Nov 2021 16:55
Only way I could get your image to show correctly was saving it as .png, I would definitely say this is a bug!

I have always had nothing but problems using .gif in game engines, is there any reason why it must be a .gif?
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 22nd Nov 2021 17:22
A common problem with 8bit Formats is that Alpha isn't an explicit channel but rather a colour within the Palette (up to 256)., as such it used to be a common issue that when you couldn't set a Chroma Key Colour (what you use for Alpha) and instead "Black" is used., this would result in both Black (0,0,0) if used and Transparency would both be used to generate an Alpha Channel.

The way around this is to use a Value between (1,1,1) and (15,15,15) as your Black Value... this is actually low enough that even with Full sRGB you're not going to notice it isn't black; but in Limited sRGB (which you'll find will be the most common)., these values will all display as the same "Blackest" value; even if they're different.
It's the same for values above 196 displaying as "White" but you can't get away with that as much with Full sRGB as that is more noticeable; and hence why Full sRGB will look Brighter and more Colourful.

But still the point remains., only use "Pure Black" for Transparency / Alpha... use an Off-Black for Black as a Colour.
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 22nd Nov 2021 18:55 Edited at: 22nd Nov 2021 18:55
i thought .gif support was added as an afterthought and only lightly supported? mainly as simple animation?
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 22nd Nov 2021 20:56
it was only added a few versions ago, Raven made some good points on why to avoid them, I encountered this years ago in GameMaker: Studio, and I always wondered why the GM:S crew always used green backgrounds on sprites... it suddenly makes sense!

its not a bug, its a feature!
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
Dale Schultz
2
Years of Service
User Offline
Joined: 1st Nov 2021
Location: Maine, USA
Posted: 22nd Nov 2021 22:00 Edited at: 22nd Nov 2021 22:32
Thanks, yes I do also think its a bug.... ( or a poor implementation without a way to select which color to use) -

and using a slightly not black color makes it almost impossible to edit the image...

Now that I know its not my bad code, I'll switch to PNG files for the AppGameKit app.
I share files between projects that use VB6 and AppGameKit and I don't think VB6 handles PNG
Dale Schultz
2
Years of Service
User Offline
Joined: 1st Nov 2021
Location: Maine, USA
Posted: 10th Feb 2022 21:21
well I thought this was the answer:

Quote: "But still the point remains., only use "Pure Black" for Transparency / Alpha... use an Off-Black for Black as a Colour."


however I have run into this issue again (different project).

The results are rather unpredictable.
I have tried with both gif and png files with the same results.

Images with non transparent pixels sometimes do not show up depending on the background color of the sprite.

As, I say I cannot see a pattern of behavior yet it seems that if the background is close to 'black' then it influences both transparent and non-transparent pixels in the image

I also found that with a black background, pixels must be at least 15 units away from 0,0,0 to regarded as not transparent, not just one. In other words the 'almost' black is visibly not black.

Here is a file that has yellow and green areas:



No matter what background this is placed on, I believe that the area around the signal head should be transparent and the signal head should always be 'very black' and the green and yellow lights should always be pure colours.

Login to post a reply

Server time is: 2024-03-29 06:57:02
Your offset time is: 2024-03-29 06:57:02