diff --git a/src/app.rs b/src/app.rs index 868d470..5acdf05 100644 --- a/src/app.rs +++ b/src/app.rs @@ -759,7 +759,9 @@ impl App { }; color_space = format!("{color_space}: {color_str}"); } - ui.label(color_space); + if ui.label(color_space).clicked() { + self.color_space_visible = true; + } } } ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { diff --git a/src/app/save_image.rs b/src/app/save_image.rs index 73e9b2c..1e6a8d9 100644 --- a/src/app/save_image.rs +++ b/src/app/save_image.rs @@ -16,7 +16,7 @@ use super::{ preferences::PREFERENCES, }; use crate::{ - image_io::save::{exr, farbfeld, gif, jpeg, save_with_format, tiff, webp, webp_animation}, + image_io::save::{gif, jpeg, save_with_format, webp, webp_animation}, util::{Image, ImageData, UserEvent}, WgpuState, }; @@ -103,8 +103,8 @@ pub fn save( } "ico" => save_with_format(path, &frames[0], ImageFormat::Ico), "tga" => save_with_format(path, &frames[0], ImageFormat::Tga), - "ff" | "farbfeld" => farbfeld(path, &frames[0]), - "tiff" | "tif" => tiff(path, &frames[0]), + "ff" | "farbfeld" => save_with_format(path, &frames[0], ImageFormat::Farbfeld), + "tiff" | "tif" => save_with_format(path, &frames[0], ImageFormat::Tiff), "gif" => gif(path, frames), "webp" => { let (quality, lossy) = match get_webp_quality(dialog_proxy.clone()) { @@ -121,7 +121,7 @@ pub fn save( webp(path, &frames[0], quality, lossy) } } - "exr" => exr(path, &frames[0]), + "exr" => save_with_format(path, &frames[0], ImageFormat::OpenExr), _ => { path.set_extension("png"); save_with_format(path, &frames[0], ImageFormat::Png) diff --git a/src/image_io/save.rs b/src/image_io/save.rs index d11f4fa..0586f7c 100644 --- a/src/image_io/save.rs +++ b/src/image_io/save.rs @@ -6,15 +6,12 @@ use std::{ }; use image::{ - codecs::{ - farbfeld::FarbfeldEncoder, gif::GifEncoder, jpeg::JpegEncoder, openexr::OpenExrEncoder, - tiff::TiffEncoder, - }, - EncodableLayout, Frame, GenericImageView, ImageEncoder, ImageError, ImageFormat, + codecs::{gif::GifEncoder, jpeg::JpegEncoder}, + Frame, GenericImageView, ImageError, ImageFormat, }; use webp_animation::prelude::*; -use crate::util::{HasAlpha, Image}; +use crate::util::Image; type SaveResult = Result; @@ -117,24 +114,6 @@ pub fn save_with_format( Ok(()) } -#[inline] -pub fn tiff(path: impl AsRef, image: &Image) -> SaveResult<()> { - let temp_path = get_temp_path(path.as_ref()); - let file = open_file(&temp_path)?; - - let encoder = TiffEncoder::new(BufWriter::new(file)); - let buffer = image.buffer(); - - encoder.encode( - buffer.as_bytes(), - buffer.width(), - buffer.height(), - buffer.color().into(), - )?; - - Ok(fs::rename(temp_path, path)?) -} - #[inline] pub fn jpeg(path: impl AsRef, image: &Image, quality: u8) -> SaveResult<()> { let temp_path = get_temp_path(path.as_ref()); @@ -165,20 +144,6 @@ pub fn gif(path: impl AsRef, images: Vec) -> SaveResult<()> { Ok(fs::rename(temp_path, path)?) } -#[inline] -pub fn farbfeld(path: impl AsRef, image: &Image) -> SaveResult<()> { - let temp_path = get_temp_path(path.as_ref()); - let file = open_file(&temp_path)?; - let encoder = FarbfeldEncoder::new(BufWriter::new(file)); - encoder.encode( - image.buffer().to_rgba16().as_bytes(), - image.buffer().width(), - image.buffer().height(), - )?; - - Ok(fs::rename(temp_path, path)?) -} - #[inline] pub fn webp_animation( path: impl AsRef, @@ -245,29 +210,3 @@ pub fn webp(path: impl AsRef, image: &Image, quality: f32, lossy: bool) -> Ok(fs::rename(temp_path, path)?) } - -#[inline] -pub fn exr(path: impl AsRef, image: &Image) -> SaveResult<()> { - let temp_path = get_temp_path(path.as_ref()); - let file = open_file(&temp_path)?; - let encoder = OpenExrEncoder::new(BufWriter::new(file)); - let (width, height) = image.buffer().dimensions(); - - if image.buffer().has_alpha() { - encoder.write_image( - image.buffer().to_rgba32f().as_bytes(), - width, - height, - image::ColorType::Rgba32F.into(), - )?; - } else { - encoder.write_image( - image.buffer().to_rgb32f().as_bytes(), - width, - height, - image::ColorType::Rgb32F.into(), - )?; - } - - Ok(fs::rename(temp_path, path)?) -}