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

Use enlargeable types in to_luma functions. #1651

Merged
merged 2 commits into from
Jan 16, 2022

Conversation

HeroicKatora
Copy link
Member

This is an attempt to fix #1214, using the Enlargeable trait to
select a suitable type for the calculation in rgb_to_luma and
bgr_to_luma.

Integer pixel types will use suitable integer pixel types for the
calculation, while floating point pixel types will use floating point
types.

This PR also provides the Enlargeable trait for all Primitive
types (luckily, Primitive is not implemented for 128 bit numeric
types).

The Color implementation of all library-defined structs is then
restricted to a subset of Primitive channel types. This is necessary to
allow its conversion operations to utilize the private Enlargeable.
Notably however we relax the type itself to not utilize any trait
bound. It's a simple wrapper around an array now.

Rebase of #1215 which was auto-closed due to deleted base branch..

This is an attempt to fix image-rs#1214, using the `Enlargeable` trait to
select a suitable type for the calculation in `rgb_to_luma` and
`bgr_to_luma`.

Integer pixel types will use suitable integer pixel types for the
calculation, while floating point pixel types will use floating point
types.

This PR also provides the `Enlargeable` trait for all `Primitive`
types (luckily, `Primitive` is not implemented for 128 bit numeric
types).

The `Color` implementation of all library-defined structs is then
restricted to a subset of Primitive channel types. This is necessary to
allow its conversion operations to utilize the private `Enlargeable`.
Notably however we _relax_ the type itself to not utilize any trait
bound. It's a simple wrapper around an array now.
@HeroicKatora HeroicKatora mentioned this pull request Jan 15, 2022
22 tasks
@HeroicKatora
Copy link
Member Author

HeroicKatora commented Jan 15, 2022

@fintelia Other concerns with the public change of this PR? It overlaps with reworking the Pixel trait in that if we removed invert and color conversion as originally sketched in #1099 then it might be possible to relax this to Primitive again.

@HeroicKatora
Copy link
Member Author

These are the two API breaking issues still open from 0.24. We could also do a release just to get it out and then work hard on actually fixing color, with conversion and better buffer API, in a 0.25.

@fintelia
Copy link
Contributor

I think maybe merge this and then roll out a 0.24? A broader Pixel rework for 0.25 seems reasonable to me.

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

Successfully merging this pull request may close these issues.

to_luma methods can have floating point issues
3 participants