Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a downsampling fuction in JuicyPixels? #100

Open
cies opened this issue Jul 26, 2015 · 3 comments
Open

Is there a downsampling fuction in JuicyPixels? #100

cies opened this issue Jul 26, 2015 · 3 comments

Comments

@cies
Copy link

cies commented Jul 26, 2015

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?

@Twinside
Copy link
Owner

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

@cies
Copy link
Author

cies commented Jul 27, 2015

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.

@Twinside
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants