Skip to content

Commit

Permalink
Simplify PngDecoder::gamma_value to use source_gamma field
Browse files Browse the repository at this point in the history
  • Loading branch information
fintelia committed Sep 20, 2023
1 parent 7a1970f commit b8437dc
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/codecs/png.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,16 +202,11 @@ impl<R: Read> PngDecoder<R> {
/// > capable of colour management are recommended to ignore the gAMA and cHRM chunks, and use
/// > the values given above as if they had appeared in gAMA and cHRM chunks.
pub fn gamma_value(&self) -> ImageResult<Option<f64>> {
let gamma = if self.reader.info().srgb.is_some() {
Some(0.45455)
} else {
self.reader
.info()
.gama_chunk
.map(|x| x.into_scaled() as f64 / 100000.0)
};

Ok(gamma)
Ok(self
.reader
.info()
.source_gamma
.map(|x| x.into_scaled() as f64 / 100000.0))
}

/// Turn this into an iterator over the animation frames.
Expand Down

0 comments on commit b8437dc

Please sign in to comment.