Handle paletted images with implicit transparency values#47
Conversation
| if read_as_paletted | ||
| palette_length = Ref{Cint}() | ||
| # TODO: Figure out the lenght of paletted before calling png_get_PLTEs | ||
| palette_buffer = Vector{RGB{N0f8}}(undef, PNG_MAX_PALETTE_LENGTH) |
There was a problem hiding this comment.
Can't we use png_get_palette_max(png_ptr, info_ptr) documented in http://www.libpng.org/pub/png/libpng-manual.txt, and thus avoid using PNG_MAX_PALETTE_LENGTH ?
There was a problem hiding this comment.
I tried that and I can't get any other output than 0 (I did call it after png_read_image). I think I tried it before and gave up:). It is a good point, though, just don't know how to make it work. I'll keep the comment for now.
There was a problem hiding this comment.
I'll create an issue for this. If the approach you discovered (using transformations) is faster, it would be nice to get rid of this hack:)
johnnychen94
left a comment
There was a problem hiding this comment.
Looks good to me; can't say too much without a test sample to diagnose this.
|
Hey, @t-bltg, would you mind if I add https://aws1.discourse-cdn.com/business5/uploads/julialang/original/3X/5/c/5c5cdaa477dcae516c7183c3e710ef65a0bb6ab0.png as a test case? I don't have any other image where palette color count != palette transparency count |
Of course you can ! Its size makes it ideal for testing ;) |
So I can make it work by applying a transformation and if the whole palette computation block is moved after |
ed5ba40 to
ddd3c65
Compare
Co-authored-by: t-bltg <tf.bltg@gmail.com>
When loading paletted images, the color and transparency components for the pallet are queried separately. Apparently, there can be fewer transparency values than color values, in which case the color values without a transparency values should be opaque. Previously we assumed there is equal count of color and transparency values -- this PR fixes that.