Open
Description
Let me try to start a future-looking discussion about support for gainmaps. I say “future-looking” because AFAIK:
- The work to add gainmaps to the PNG spec is still in progress (see Proposal: gain maps for PNG w3c/png#380).
- Support for gain maps is not a blocker for adopting Rust
png
in Chromium. (At least not from Chromium Security perspective, since we care mostly about parity withlibpng
/SkPngCodec
/blink::PNGImageDecoder
and none of them support gain maps today.)
But, despite the caveats above, I think it’s still desirable to start some early discussions on how Rust png
crate API could potentially accommodate gain maps:
- I assume that
next_frame
and/ornext_interlaced_row
APIs would also work for decoding the hypotheticalgDAT
chunks.- IIUC the
gDAT
output color type may be different from that ofIDAT
/fDAT
. I don’t know if this is a problem (e.g. ifReader.output_color_type
and/orReader.output_buffer_size
APIs would need to evolve, or get gain-map-specific sibling methods).
- IIUC the
- I assume that a method like
next_frame_info
can be used to seek to the start of the next sequence ofIDAT
/fDAT
/gDAT
chunks- IIUC
next_frame_info
’s PR has been merged relatively recently and so it hasn’t yet been released on crates.io (and therefore breaking changes are not a concern at this point)- Today
next_frame_info
returns&FrameControl
which won't work whengDAT
doesn't have a precedingfCTL
.
- Today
- There probably should be an API to indicate if the next frame is
gDAT
vsIDAT
orfDAT
:- Maybe we need to introduce
enum ImageDataKind { /* IDAT ? */ fDAT, gDAT }
? - Maybe
next_frame_info
can returnImageDataKind
? (this wouldn't help with identifying the very first image, but the current spec proposal implies thatIDAT
would always remain the first image data kind - this is why I've tentatively commented outIDAT
above) - Or as an alternative we could add
Info.current_image_data_kind
orinfo.next_image_data_kind
? (it should work, but it feels weird that it would be sort of undefined between the end ofxDAT
and before the start of the nextyDAT
sequence)
- Maybe we need to introduce
- IIUC
- I assume that representing
gMAP
chunk inInfo
struct is pretty straightforward (once the spec discussion settle down and we know what this chunk actually covers).
Metadata
Metadata
Assignees
Labels
No labels