diff options
Diffstat (limited to 'engine')
| -rw-r--r-- | engine/Cargo.toml | 2 | ||||
| -rw-r--r-- | engine/src/image.rs | 10 | ||||
| -rw-r--r-- | engine/src/renderer/opengl.rs | 6 |
3 files changed, 16 insertions, 2 deletions
diff --git a/engine/Cargo.toml b/engine/Cargo.toml index 9461ee9..424d09b 100644 --- a/engine/Cargo.toml +++ b/engine/Cargo.toml @@ -26,7 +26,7 @@ default-features = false features = ["rwh_06", "wayland", "wayland-dlopen", "x11"] [dependencies.image_rs] -version = "0.24.7" +version = "0.25.10" default-features = false features = ["png", "jpeg"] package = "image" diff --git a/engine/src/image.rs b/engine/src/image.rs index 7c18bf7..cf31a92 100644 --- a/engine/src/image.rs +++ b/engine/src/image.rs @@ -20,7 +20,7 @@ impl Image let buffered_reader = BufReader::new(File::open(&path).map_err(Error::ReadFailed)?); - let image_reader = image_rs::io::Reader::with_format( + let image_reader = image_rs::ImageReader::with_format( buffered_reader, image_rs::ImageFormat::from_path(path) .map_err(|_| Error::UnsupportedFormat)?, @@ -60,6 +60,14 @@ impl Image self.inner.color().into() } + pub fn color_space_is_srgb(&self) -> bool + { + match self.inner.color_space().primaries { + image_rs::metadata::CicpColorPrimaries::SRgb => true, + _ => false, + } + } + pub fn as_bytes(&self) -> &[u8] { self.inner.as_bytes() diff --git a/engine/src/renderer/opengl.rs b/engine/src/renderer/opengl.rs index a280073..11a4ca9 100644 --- a/engine/src/renderer/opengl.rs +++ b/engine/src/renderer/opengl.rs @@ -45,6 +45,7 @@ use opengl_bindings::shader::{ // UniformLocation as GlUniformLocation, }; use opengl_bindings::texture::{ + ColorSpace as GlTextureColorSpace, Filtering as GlTextureFiltering, GenerateError as GlTextureGenerateError, PixelDataFormat as GlTexturePixelDataFormat, @@ -1145,6 +1146,11 @@ fn create_gl_texture( unimplemented!(); } }, + if image.color_space_is_srgb() { + GlTextureColorSpace::Srgb + } else { + GlTextureColorSpace::Linear + }, )?; gl_texture.set_wrap( |
