image-rs / jpeg-decoder

JPEG decoder written in Rust
Apache License 2.0
150 stars 87 forks source link

Override colour transform #255

Closed AlanRace closed 1 year ago

AlanRace commented 1 year ago

Added the ability to set the colour transform applied (resolves https://github.com/image-rs/jpeg-decoder/issues/238).

To do this, I had added a new enum which captures the possible options, including a Default option which retains the previous behaviour when the color_transform == None.

AlanRace commented 1 year ago

Hopefully this should now resolve the previous ambiguity.

I decided that the presence of app segments should set color_transform rather than overwriting fallback_color_transform, but that's a simple change if you prefer it the other way.

AlanRace commented 1 year ago

As this pull request is dealing with colour transforms, I had a look at solving https://github.com/image-rs/jpeg-decoder/issues/249 too. I have rewritten the logic for selecting the colour transform based on the information here.

That (hopefully) removes the need for the fallback transform being set, so I have removed it. Let me know what you think.