#[non_exhaustive]pub struct Ratio {
pub numerator: u16,
pub denominator: u16,
pub exponent: i8,
}Expand description
A resolution as the file stores it: numerator / denominator × 10^exponent
grid points per meter. Kept as integers, so the value is exact;
Ratio::grid_points_per_meter gives it as a float.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.numerator: u16N.
denominator: u16D.
exponent: i8E, a power of ten.
Implementations§
Source§impl Ratio
impl Ratio
Sourcepub fn grid_points_per_meter(self) -> Option<f64>
pub fn grid_points_per_meter(self) -> Option<f64>
The resolution in grid points per meter, or None when the
denominator is 0.
use rust_j2k::read_header;
let bytes = jp2_with_resolution(&codestream)?;
let jp2 = read_header(&bytes)?.jp2.expect("a JP2 file");
let capture = jp2.resolution.capture.expect("a capture resolution");
// 10000 / 254 is about 39.37 grid points per meter.
let per_meter = capture.horizontal.grid_points_per_meter().unwrap();
assert!((per_meter - 10000.0 / 254.0).abs() < 1e-9);Trait Implementations§
impl Copy for Ratio
impl Eq for Ratio
impl StructuralPartialEq for Ratio
Auto Trait Implementations§
impl Forget for Ratio
impl Freeze for Ratio
impl Move for Ratio
impl RefUnwindSafe for Ratio
impl Send for Ratio
impl Sync for Ratio
impl Unpin for Ratio
impl UnsafeUnpin for Ratio
impl UnwindSafe for Ratio
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more