editing: Fix preroateted images
Editing does not work correctly if PNGs or JPEGs are already rotated via an Exif orientation entry before editing. This needs the glycin-image-rs 1.2.1 loader to work correctly. Closes #481
This commit is contained in:
parent
a49096ffde
commit
ef5f94859b
10 changed files with 74 additions and 40 deletions
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2024 Sophie Herold
|
||||
// Copyright (c) 2024-2025 Sophie Herold
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -15,6 +15,7 @@
|
|||
//
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
use glycin::Operations;
|
||||
use tiling::RenderOptions;
|
||||
|
||||
use super::*;
|
||||
|
|
@ -26,19 +27,25 @@ impl imp::LpImage {
|
|||
node: gsk::RenderNode,
|
||||
snapshot: >k::Snapshot,
|
||||
) -> Result<(), crate::editing::preview::EditingError> {
|
||||
if let Some(operations) = self.operations.borrow().as_ref() {
|
||||
let (width, height) = self.original_dimensions();
|
||||
let new_dimensions = crate::editing::preview::apply_operations(
|
||||
node,
|
||||
width as u32,
|
||||
height as u32,
|
||||
operations,
|
||||
snapshot,
|
||||
self.applicable_zoom(),
|
||||
)?;
|
||||
let (width, height) = self.original_dimensions();
|
||||
|
||||
self.overwrite_dimensions.set(Some(new_dimensions));
|
||||
}
|
||||
let initial_operations = if let Some(orientation) = self.original_orientation.get() {
|
||||
Operations::new_orientation(orientation)
|
||||
} else {
|
||||
Operations::new(Vec::new())
|
||||
};
|
||||
|
||||
let new_dimensions = crate::editing::preview::apply_operations(
|
||||
node,
|
||||
width as u32,
|
||||
height as u32,
|
||||
self.operations.borrow().as_ref().map(|x| x.as_ref()),
|
||||
snapshot,
|
||||
self.applicable_zoom(),
|
||||
&initial_operations,
|
||||
)?;
|
||||
|
||||
self.overwrite_dimensions.set(Some(new_dimensions));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,14 +114,6 @@ impl WidgetImpl for imp::LpImage {
|
|||
let y = obj.image_rendering_y();
|
||||
snapshot.translate(&graphene::Point::new(x as f32, y as f32));
|
||||
|
||||
// Apply rotation and mirroring
|
||||
self.snapshot_rotate_mirror(
|
||||
snapshot,
|
||||
obj.rotation() as f32,
|
||||
obj.mirrored(),
|
||||
applicable_zoom,
|
||||
);
|
||||
|
||||
// Add texture(s)
|
||||
|
||||
// Don't use current frame buffer if it empty during an image reload
|
||||
|
|
@ -138,6 +130,14 @@ impl WidgetImpl for imp::LpImage {
|
|||
log::error!("Render node is empty");
|
||||
}
|
||||
} else {
|
||||
// Apply rotation and mirroring
|
||||
self.snapshot_rotate_mirror(
|
||||
snapshot,
|
||||
obj.rotation() as f32,
|
||||
obj.mirrored(),
|
||||
applicable_zoom,
|
||||
);
|
||||
|
||||
frame_buffer.add_to_snapshot(snapshot, applicable_zoom, &render_options);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue