#[non_exhaustive]#[repr(u8)]pub enum Orientation {
Identity = 1,
FlipH = 2,
Rotate180 = 3,
FlipV = 4,
Transpose = 5,
Rotate90 = 6,
Transverse = 7,
Rotate270 = 8,
}Expand description
Full re-export of zenpixels core types (zero module name collisions!).
Image orientation — the 8-element D4 dihedral group.
Values 1-8 match EXIF tag 274 exactly.
#[repr(u8)] means o as u8 gives the EXIF value directly.
§Decomposition
| Variant | Rotation | FlipH? | Swaps axes? |
|------------|----------|--------|-------------|
| Identity | 0° | no | no |
| FlipH | 0° | yes | no |
| Rotate180 | 180° | no | no |
| FlipV | 180° | yes | no |
| Transpose | 90° CW | yes | yes |
| Rotate90 | 90° CW | no | yes |
| Transverse | 270° CW | yes | yes |
| Rotate270 | 270° CW | no | yes |§D4 group operations
then implements group multiplication (verified
against a full Cayley table). inverse returns the
element that undoes the transformation.
use zenpixels::Orientation;
let combined = Orientation::Rotate90.then(Orientation::FlipH);
assert_eq!(combined, Orientation::Transpose);
let roundtrip = Orientation::Rotate90.then(Orientation::Rotate90.inverse());
assert_eq!(roundtrip, Orientation::Identity);Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Identity = 1
No transformation. EXIF 1.
FlipH = 2
Horizontal flip (mirror left-right). EXIF 2.
Rotate180 = 3
180° rotation. EXIF 3.
FlipV = 4
Vertical flip (= Rotate180 + FlipH). EXIF 4.
Transpose = 5
Transpose: reflect over main diagonal (= Rotate90 + FlipH). EXIF 5. Swaps axes.
Rotate90 = 6
90° clockwise rotation. EXIF 6. Swaps axes.
Transverse = 7
Transverse: reflect over anti-diagonal (= Rotate270 + FlipH). EXIF 7. Swaps axes.
Rotate270 = 8
270° clockwise rotation (= 90° counter-clockwise). EXIF 8. Swaps axes.
Implementations§
Source§impl Orientation
impl Orientation
Sourcepub const ALL: [Orientation; 8]
pub const ALL: [Orientation; 8]
All 8 orientations in EXIF order (1-8).
Sourcepub const fn from_exif(value: u8) -> Option<Orientation>
pub const fn from_exif(value: u8) -> Option<Orientation>
Create from EXIF orientation tag value (1-8).
Returns None for values outside 1-8. Use .unwrap_or_default()
if you want fallback to Identity.
Sourcepub const fn to_exif(self) -> u8
pub const fn to_exif(self) -> u8
Convert to EXIF orientation tag value (1-8).
Equivalent to self as u8 thanks to #[repr(u8)].
Sourcepub const fn is_identity(self) -> bool
pub const fn is_identity(self) -> bool
Whether this is the identity (no-op) transformation.
Sourcepub const fn swaps_axes(self) -> bool
pub const fn swaps_axes(self) -> bool
Whether this orientation swaps width and height.
True for orientations involving a 90° or 270° rotation (EXIF 5-8).
Sourcepub const fn keeps_row_index(self) -> bool
pub const fn keeps_row_index(self) -> bool
Sourcepub const fn then(self, next: Orientation) -> Orientation
pub const fn then(self, next: Orientation) -> Orientation
Chain two orientations: apply self first, then next.
This is D4 group multiplication, verified against the full Cayley table:
Orientation::Rotate90.then(Orientation::FlipH) means “apply Rotate90 first, then FlipH.”
Sourcepub const fn inverse(self) -> Orientation
pub const fn inverse(self) -> Orientation
The inverse orientation: self.then(self.inverse()) == Identity.
Sourcepub const fn output_dimensions(self, width: u32, height: u32) -> (u32, u32)
pub const fn output_dimensions(self, width: u32, height: u32) -> (u32, u32)
Compute output dimensions after applying this orientation.
Returns (width, height) — swapped when swaps_axes is true.
Sourcepub const fn map_pixel_coordinates(
self,
source_xy: (u32, u32),
source_dimensions: (u32, u32),
) -> (u32, u32)
pub const fn map_pixel_coordinates( self, source_xy: (u32, u32), source_dimensions: (u32, u32), ) -> (u32, u32)
Forward-map a source pixel coordinate source_xy = (sx, sy) to its destination
position (dx, dy) in the oriented output image.
source_dimensions = (width, height) are the source (pre-orientation) dimensions.
Trait Implementations§
Source§impl Clone for Orientation
impl Clone for Orientation
Source§fn clone(&self) -> Orientation
fn clone(&self) -> Orientation
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for Orientation
Source§impl Debug for Orientation
impl Debug for Orientation
Source§impl Default for Orientation
impl Default for Orientation
Source§fn default() -> Orientation
fn default() -> Orientation
impl Eq for Orientation
Source§impl From<Orientation> for Orientation
Available on crate feature image only.
impl From<Orientation> for Orientation
image only.