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

Feature request: get_palette() for P4 and P8 modes and PNGs #994

Open
LionsPhil opened this issue Sep 8, 2024 · 3 comments
Open

Feature request: get_palette() for P4 and P8 modes and PNGs #994

LionsPhil opened this issue Sep 8, 2024 · 3 comments
Labels

Comments

@LionsPhil
Copy link
Contributor

Since PNGdec has been added, you can now load and set the palette along with an image using PNG_COPY. However, there's no way to get the palette from PNGdec I can see (even undocumented), nor a way to read the current palette from PicoGraphics.

A reason to want this is for palette cycling. This is a nice cheap way to get some animation without having to slowly push new pixels to the display. (You could also do fadeouts, if you really wanted.) Being able to get the palette from the image one way or another (and via PicoGraphics seems the more reasonable) would let me replace the custom image format I'm using with just PNG.

@LionsPhil
Copy link
Contributor Author

Actually, it's possible I've misunderstood what PNG_COPY does...it doesn't set the palette, does it? Instead it assumes the display palette and the image palette are the same (or you want do color remapping tricks) and just copies indicies.

So I guess I'm actually asking for a way to get the palette out of a loaded PNG after all.

@LionsPhil LionsPhil changed the title Feature request: get_palette() for P4 and P8 modes Feature request: get_palette() for P4 and P8 modes and PNGs Sep 9, 2024
@Gadgetoid
Copy link
Member

I can't remember off the top of my head how straight-forward this is likely to be, but it makes sense and it's on my long list of things to prod and poke when I get the time!

@Gadgetoid
Copy link
Member

Gadgetoid commented Sep 26, 2024

At a wild guess - it's been so long since I looked into this - the existing get_palette only works after displaying a PNG?

Ah, it looks like it uses decode() to load the palette, but passes in a nullptr for the userdata which might cause... things to happen (horribly crashing, memory corruption and other excitement maybe...).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants