-
-
Notifications
You must be signed in to change notification settings - Fork 851
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
Support for palette access when reading indexed image formats #2404
Comments
@Paul-JanPauptit What format are your images in? Completed
For future
|
@JimBobSquarePants I am currently in a bit of crunch so my demoscene toolbuilding is on hold for a couple of weeks, but I wanted to say that I really appreciate that you have been adding this functionality. <3 I don't have a set workflow yet, I think centering it around PNG should work perfectly. Basically being able to read out the palette and pixels should solve all my problems. |
Happy to help! I'll eventually port bitmap and maybe tiff across to do it also but will leave that for future releases as it gets complicated. |
@JimBobSquarePants Where can I find this branch? |
Support for those types has already been released. |
Great! Is there an example on reading the raw palette and indices of a 4-bit / 8-bit indexed png? |
Sure.. You need to query the metata for each type. using Image<TPixel> image = ... ;
PngMetadata metadata = image.Metadata.GetPngMetadata();
// You want to check for null here.
ReadOnlySpan<Color> colorTable = metadata.ColorTable.Value.Span; |
That's great but how do I read the indices? What pixel format do I need to read it? Most of the image libraries I've looked at for .NET convert indexed pngs' to RGB. It would be fantastic if your library can read the raw indices. Also is it possible to write indexed pngs' in both 4-bit and 8-bit indexed formats with a custom palettes? |
You don't read indices. An image buffer is a 2D representation of the decoded image pixels where the pixel format represents the requested layout in memory of each pixel. Indices are already read during decoding so there is none of that will-it-throw-an-exception nonsense you get in System.Drawing when trying to do graphics options that should be agnostic. ImageSharp will automatically decode the indexed image data into whatever pixel format you explicitly choose to use or the most memory efficient and appropriate pixel format.
Can you please keep questions focused and in the discussion channels. You should also read and understand the API docs before asking questions. (Also, yes you can) |
Okay it looks like I need to make a feature request. Thanks for your time. |
I've moved to using the pngcs library. |
Prerequisites
DEBUG
andRELEASE
modeImageSharp version
3.0.0
Other ImageSharp packages and versions
Environment (Operating system, version and so on)
Windows, any
.NET Framework version
Description
I am processing 4-bpp indexed images (16 colors) for retro & fantasy platform development (TIC80 in particular). For that we often need access to the original palette of the image.
I understand this is not a primary use case for ImageSharp, but it would be great if ImageSharp offered just that... and like @JimBobSquarePants mentioned on twitter, "why not submit an issue". 😄
Steps to Reproduce
Load an indexed image. Try to access the palette.
Images
No response
The text was updated successfully, but these errors were encountered: