PNGFiles.jl
PNGFiles.jl copied to clipboard
Figure out the length of palette before calling `png_get_PLTE`
Currently, when processing paletted images, we first prepare a palette color buffer of maximum size (PNG_MAX_PALETTE_LENGTH
, 256), then we query the file to populate the buffer and finally we resize the buffer to match the number of the color entries in the file. As @t-bltg noted (https://github.com/JuliaIO/PNGFiles.jl/pull/47#issuecomment-1001484066), there is a way to know the palette length before populating the buffer, in which case we could simply create the buffer of the correct size.
IIUC, to be able to get the palette length early, one has to use libpng transformation (see the comment referenced above), so we need to figure out how to do it and whether it's beneficial in terms of performance.