Twinside / Juicy.Pixels

Haskell library to load & save pictures

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there a downsampling fuction in JuicyPixels?

cies opened this issue · comments

I only find ways to promote pixels, or ways to drop alpha channels, but no way to reduce the bits-per-channel on a pixel.

If this does not exists can someone point my in the right direction for implementing this?

And would it be something to add to JuicyPixels? I mean: would a pull requests to JP with this functionality be welcomed?

There is none right now, the method to do this it in the case 16bit -> 8bit is to perform a bit shift to keep only the high value bits : Data.Bits.shiftR c 8. For the Float case, it's even simpler it's floor . (256 *) . max 0 . min 1.

A pull request would be welcomed, and I think it could be implemented in term of pixelMap, reducing the cases. Your question clearly shows that the design of JuicyPixels is aging and would need a major refactoring :-/

Thanks! I've also learned a bit about dithering, but figured out that it is not needed and truncating would be enough for now.

About the refactoring: I would not know if this is needed. Haven't run into any shortcomings yet.

Ah, you make me remember there is Codec.Picture.ColorQuant if you want to generate an acceptable palette, it's used for GIF saving.