Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor: support loading 8-bit images with Alpha in palette #2657

Conversation

ivan-mogilko
Copy link
Contributor

@ivan-mogilko ivan-mogilko commented Jan 15, 2025

This lets Editor to correctly import 8-bit indexed PNGs that have valid alpha component in its palette.
The previous versions of AGS loaded all PNGs as 32-bit images, which solved this problem, but made it impossible to import 8-bit PNGs as actually 8-bit images.
AGS 3.6.2 imports 8-bit PNGs as 8-bit images, but now has opposite problem: if such image has to be converted to a 32-bit sprite (in 32-bit game), the alpha channel becomes lost. First it does not detect the presence of alpha, secondly the process of converting a 8-bit image to a final sprite does not use alpha component at all.
This PR solves these issues.

EDIT: I am not very good at graphic editors, and could not yet find a way to create or export such images.
So i am attaching a sprite provided by the user who got this problem:
NE-01-SS-000.zip

1. SpriteImportWindow tests if source bitmap may contain alpha even if it's 8-bit.
2. SpriteTool tests input bitmap for alpha, and corrects "useAlphaChannel" and "remapColours" parameters accordingly.
3. AGSNative's CreateBlockFromBitmap() correctly converts input 8-bit bitmaps which palette has ARGB.
@ivan-mogilko ivan-mogilko added what: editor related to the game editor context: editor assets related to input files for editing the game labels Jan 15, 2025
@ericoporto
Copy link
Member

ericoporto commented Jan 16, 2025

I tested this and confirms it works - I was curious if it would impact #1771 but it doesn't.

The only thing I noticed in particular is that in the sprite selection, the ones that were transparent alpha 8-bit at import time got the transparent pixels to become magenta, and the ones that are 32-bit regular alpha got actual transparent pixels for the transparent pixels. This is more an observation.

image

I also noticed that while they are 8-bit at import time they get converted to 32-bit - I think this is correct, and expected and this has always been the case before, and only ags4 has the option to keep the original bitness, but I thought I should mention anyway just to confirm this doesn't change.

@ivan-mogilko
Copy link
Contributor Author

The only thing I noticed in particular is that in the sprite selection, the ones that were transparent alpha 8-bit at import time got the transparent pixels to become magenta

I did not notice this, can you clarify the sprite format and import settings?

@ivan-mogilko
Copy link
Contributor Author

@ericoporto

The only thing I noticed in particular is that in the sprite selection, the ones that were transparent alpha 8-bit at import time got the transparent pixels to become magenta,

Could you attach a image that causes this? I was not able to find how to create such indexed sprites with the graphic software that I'm used to.

@ivan-mogilko ivan-mogilko merged commit 35b029b into adventuregamestudio:master Jan 19, 2025
21 checks passed
@ivan-mogilko ivan-mogilko deleted the 362--importindexedspriteswithalpha branch January 19, 2025 21:06
@ericoporto
Copy link
Member

I tried with my own image attached in the masks test issue, here it is again

https://github.com/adventuregamestudio/ags/files/9541552/mask_test_3.zip

The other one is from Don't Give Up the Cat

https://github.com/ericoporto/dont-give-up-the-cat/blob/main/dont-give-up-the-cat/Sprites/DandelionFx/dandelion_particle_02.png

@ivan-mogilko
Copy link
Contributor Author

ivan-mogilko commented Jan 20, 2025

So, these both images are recognized as having no alpha component, that's why they have their transparency turned into "magic pink". AGS only detects an alpha component when the palette contains any color with alpha which is not 0 and not 255.

@ericoporto
Copy link
Member

It's weird that before #1772 they didn't even import because of these alphas, but that is alright, I think this doesn't change things at all in-game.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
context: editor assets related to input files for editing the game what: editor related to the game editor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants