Closed simon-frankau closed 2 years ago
I've also raised https://github.com/image-rs/image-gif/issues/109, in case they feel it should be fixed at that layer.
This has been fixed upstream in image-gif, and I've just checked that cargo update
picks it up. It does, so it's all done.
Describe the bug
When I tried to produce a plot with a single highlighted point using the gif backend (as part of an animated gif), the highlighted point did not come out in the colour I expected - I asked for bright red, and got a very dark red.
My theory is that the gif is generated by the gif package, which uses the NeuQuant algorithm, which is primarily intended to quantize images with many colours. It uses a "samping factor" to choose what fraction of pixels to sample, which I suspect makes it possible to ignore or under-weigh bright little highlights when constructing the palette.
Plotters uses a "speed" of 10 (https://docs.rs/plotters-bitmap/0.3.0/src/plotters_bitmap/bitmap.rs.html#86), as recommended. I suspect this is just the sampling factor, although I've not traced it through to the gif crate source. This makes it possible to miss sampling areas of ~10 pixels.
I imagine this might seem like a bit of a corner case, but it's surprisingly confusing when you create a plot with a single highlighted point and it just isn't highlighted!
I see a few possible responses:
You may see others. To be honest, I'd probably go with calling it an issue with the gif crate, but I want to give you first refusal. :)
If any of the other solutions appeal, I'd be happy to work on the PR.
To Reproduce
Minimised code:
Output gif attached:![out](https://user-images.githubusercontent.com/6563758/126066064-92c0475f-15a3-4c7a-b4ac-86ae902e9e23.gif)
Version Information Not quite sure how best to answer this, but my Cargo.lock has:
Thanks, Simon.