Fix bleed, fix thumbnail orientation

This commit is contained in:
Dawid Pietrykowski 2025-04-11 00:33:09 +02:00
parent 207878928f
commit b41554c608
3 changed files with 13 additions and 1 deletions

View File

@ -434,6 +434,10 @@ impl App {
fn update_transform(&mut self) { fn update_transform(&mut self) {
let state = self.state.as_mut().unwrap(); let state = self.state.as_mut().unwrap();
// TODO: Remove obviously
if state.transform_data.width < 800 {
state.transform_data.orientation = Orientation::NoTransforms;
}
let (width, height) = swap_wh( let (width, height) = swap_wh(
state.transform_data.width, state.transform_data.width,
state.transform_data.height, state.transform_data.height,

View File

@ -329,9 +329,10 @@ pub fn load_thumbnail_exif(path: &ImageData) -> Option<ImflowImageBuffer> {
let decoder = image::ImageReader::new(Cursor::new(thumbnail)) let decoder = image::ImageReader::new(Cursor::new(thumbnail))
.with_guessed_format() .with_guessed_format()
.unwrap(); .unwrap();
let image = decoder.decode().unwrap(); let mut image = decoder.decode().unwrap();
let orientation = path.orientation; let orientation = path.orientation;
image.apply_orientation(orientation);
let width: usize = image.width() as usize; let width: usize = image.width() as usize;
let height: usize = image.height() as usize; let height: usize = image.height() as usize;
let rgba_buffer = image_to_rgba_buffer(image); let rgba_buffer = image_to_rgba_buffer(image);

View File

@ -43,6 +43,13 @@ fn fs_main(@location(0) in: vec2<f32>) -> @location(0) vec4<f32> {
} }
let scale = texture_size / out_dim; let scale = texture_size / out_dim;
var pixel = uv * scale; var pixel = uv * scale;
// add offset to remove bleed from uncleared buffer
let half_texel = vec2<f32>(0.5) / out_dim;
let min_uv = half_texel;
let max_uv = scale - half_texel;
pixel = clamp(pixel, min_uv, max_uv);
if transforms.orientation == 3 { if transforms.orientation == 3 {
pixel = reverse(pixel); pixel = reverse(pixel);
} }