mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-20 11:28:30 +08:00
Add basic thumbnail extraction to Rawkit (#2659)
* Add `CompressionValue` * Rename `Transform` to `OrientationValue` * Add basic thumbnail extraction * Add `ThumbnailFormat` * fmt + clippy fixes
This commit is contained in:
committed by
GitHub
parent
d441a02e72
commit
c21ccf5284
@@ -1,16 +1,16 @@
|
||||
use crate::{Image, Pixel, Transform};
|
||||
use crate::{Image, OrientationValue, Pixel};
|
||||
|
||||
impl Image<u16> {
|
||||
pub fn transform_iter(&self) -> (usize, usize, impl Iterator<Item = Pixel> + use<'_>) {
|
||||
let (final_width, final_height) = if self.transform.will_swap_coordinates() {
|
||||
pub fn orientation_iter(&self) -> (usize, usize, impl Iterator<Item = Pixel> + use<'_>) {
|
||||
let (final_width, final_height) = if self.orientation.will_swap_coordinates() {
|
||||
(self.height, self.width)
|
||||
} else {
|
||||
(self.width, self.height)
|
||||
};
|
||||
|
||||
let index_0_0 = inverse_transform_index(self.transform, 0, 0, self.width, self.height);
|
||||
let index_0_1 = inverse_transform_index(self.transform, 0, 1, self.width, self.height);
|
||||
let index_1_0 = inverse_transform_index(self.transform, 1, 0, self.width, self.height);
|
||||
let index_0_0 = inverse_orientation_index(self.orientation, 0, 0, self.width, self.height);
|
||||
let index_0_1 = inverse_orientation_index(self.orientation, 0, 1, self.width, self.height);
|
||||
let index_1_0 = inverse_orientation_index(self.orientation, 1, 0, self.width, self.height);
|
||||
|
||||
let column_step = (index_0_1.0 - index_0_0.0, index_0_1.1 - index_0_0.1);
|
||||
let row_step = (index_1_0.0 - index_0_0.0, index_1_0.1 - index_0_0.1);
|
||||
@@ -42,16 +42,16 @@ impl Image<u16> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn inverse_transform_index(transform: Transform, mut row: usize, mut column: usize, width: usize, height: usize) -> (i64, i64) {
|
||||
let value = match transform {
|
||||
Transform::Horizontal => 0,
|
||||
Transform::MirrorHorizontal => 1,
|
||||
Transform::Rotate180 => 3,
|
||||
Transform::MirrorVertical => 2,
|
||||
Transform::MirrorHorizontalRotate270 => 4,
|
||||
Transform::Rotate90 => 6,
|
||||
Transform::MirrorHorizontalRotate90 => 7,
|
||||
Transform::Rotate270 => 5,
|
||||
pub fn inverse_orientation_index(orientation: OrientationValue, mut row: usize, mut column: usize, width: usize, height: usize) -> (i64, i64) {
|
||||
let value = match orientation {
|
||||
OrientationValue::Horizontal => 0,
|
||||
OrientationValue::MirrorHorizontal => 1,
|
||||
OrientationValue::Rotate180 => 3,
|
||||
OrientationValue::MirrorVertical => 2,
|
||||
OrientationValue::MirrorHorizontalRotate270 => 4,
|
||||
OrientationValue::Rotate90 => 6,
|
||||
OrientationValue::MirrorHorizontalRotate90 => 7,
|
||||
OrientationValue::Rotate270 => 5,
|
||||
};
|
||||
|
||||
if value & 4 != 0 {
|
||||
|
||||
Reference in New Issue
Block a user