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

Use ST palette for PNG screenshots if possible #30

Closed
wants to merge 6 commits into from

Conversation

bbbradsmith
Copy link
Contributor

Tried this out in response to a discussion from the mailing list. It allows PNG screenshots to use the ST palette where possible.

A palettized image has a few advantages. The file size is slightly smaller. Any graphics program that can view the palette can now be used to see what the ST's 16-colour palette looked like at the time of screenshot. It makes palette-based editing of the image easier (e.g. changing colours). Conversion into an ST-ready image format is also more straightforward.

This automatically falls back to a full RGB image if the image contains any colours outside the current ST palette. This means that modes with more colours, or mid-screen palette changes will still produce valid screenshots as full RGB.

In the case where the palette has multiple colours that are identical, they will all be remapped to the first colour with that index. So, if all 16 colours are unique, it will be a 1:1 mapping to the ST in-memory image, but if there is ambiguity it will still show the correct colour, just with potentially the wrong index. A "perfect" version would maybe use the current video memory contents to disambiguate this case, but that would be a bit more complicated to accomplish. This PR instead does the best it can with only the output image and current known palette.

@bbbradsmith
Copy link
Contributor Author

Added support for GenConvert so high resolution, TT, Falcon, etc. are capable of using the palettes too.

Tested PNG AVI output as well, which appears to have no problem with indexed PNGs, even if their palette changes over time.

@huth
Copy link
Member

huth commented Jan 14, 2024

I now had a quick look at your patches here, and I think the whole PixelConvert_16to8Bits() should not be necessary anymore. Hatari now always uses 32 bpp for indexed ST screens (see commit 4d78e24).

Also, could you please rebase your patches to the current upstream master branch (and squash the typo fix and the other fixes into the corresponding patches)? Thanks!

huth pushed a commit that referenced this pull request Jan 15, 2024
Notes from Brad Smith (#30) :
This allows PNG screenshots to use the ST palette where possible.

A palettized image has a few advantages. The file size is slightly smaller.
Any graphics program that can view the palette can now be used to see what
the ST's 16-colour palette looked like at the time of screenshot. It makes
palette-based editing of the image easier (e.g. changing colours).
Conversion into an ST-ready image format is also more straightforward.

This automatically falls back to a full RGB image if the image contains any
colours outside the current ST palette. This means that modes with more colours,
or mid-screen palette changes will still produce valid screenshots as full RGB.

This works for low res and med res video modes.

NOTE 2 : As the Hatari UI also uses its own colors, you need to check "Crop Statusbar"
in the "Hatari Screen" menu to ensure the status bar is not included in the
screenshot. If not, it will use more colors than the emulated screen and resulting
PNG will be saved as RGB image and not as palettized image.
@huth
Copy link
Member

huth commented Jan 15, 2024

Looks like @npomarede went ahead and included your patch (with the fixes squashed). Thus I think we can close this pull request now.

@huth huth closed this Jan 15, 2024
@bbbradsmith bbbradsmith deleted the snapshot-palette branch April 15, 2024 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants