Juicy.Pixels icon indicating copy to clipboard operation
Juicy.Pixels copied to clipboard

Is there a downsampling fuction in JuicyPixels?

Open cies opened this issue 9 years ago • 3 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?

cies avatar Jul 26 '15 12:07 cies

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 :-/

Twinside avatar Jul 27 '15 09:07 Twinside

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.

cies avatar Jul 27 '15 12:07 cies

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

Twinside avatar Jul 27 '15 14:07 Twinside