Skip to content

Conversation

@197g
Copy link
Member

@197g 197g commented Jan 12, 2022

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.
@197g 197g mentioned this pull request Jan 15, 2022
22 tasks
@197g
Copy link
Member Author

197g 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.

@197g
Copy link
Member Author

197g commented Jan 15, 2022

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