Struct PixelDensity

pub struct PixelDensity { pub density: (u16, u16), pub unit: PixelDensityUnit }

Represents the pixel density of an image

For example, a 300 DPI image is represented by:

use image::codecs::jpeg::*;
let hdpi = PixelDensity::dpi(300);
assert_eq!(hdpi, PixelDensity {density: (300,300), unit: PixelDensityUnit::Inches})

Fields

density: (u16, u16)

A couple of values for (Xdensity, Ydensity)

unit: PixelDensityUnit

The unit in which the density is measured

Implementations

impl PixelDensity

fn dpi(density: u16) -> Self

Creates the most common pixel density type: the horizontal and the vertical density are equal, and measured in pixels per inch.

Trait Implementations

impl Clone for PixelDensity

fn clone(&self) -> PixelDensity

impl Copy for PixelDensity

impl Debug for PixelDensity

fn fmt(&self, f: &mut Formatter<'_>) -> Result

impl Default for PixelDensity

fn default() -> Self

Returns a pixel density with a pixel aspect ratio of 1

impl Eq for PixelDensity

impl PartialEq for PixelDensity

fn eq(&self, other: &PixelDensity) -> bool

impl StructuralPartialEq for PixelDensity

Auto Trait Implementations

impl Freeze for PixelDensity

impl RefUnwindSafe for PixelDensity

impl Send for PixelDensity

impl Sync for PixelDensity

impl Unpin for PixelDensity

impl UnsafeUnpin for PixelDensity

impl UnwindSafe for PixelDensity

Blanket Implementations

impl<R, P> ReadPrimitive<R> for PixelDensity where R: Read + ReadEndian<P>, P: Default,

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for PixelDensity where ST: ?Sized, DT: ?Sized,

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for PixelDensity where ST: ?Sized, DT: ?Sized,

impl<T> Any for PixelDensity where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for PixelDensity where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for PixelDensity where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> CloneToUninit for PixelDensity where T: Clone,

unsafe fn clone_to_uninit(&self, dest: *mut u8)

impl<T> From<T> for PixelDensity

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> IntoEither for PixelDensity

impl<T> Pointable for PixelDensity

const ALIGN: usize = _;
type Init = T;
unsafe fn init(init: <T as Pointable>::Init) -> usize
unsafe fn deref<'a>(ptr: usize) -> &'a T
unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
unsafe fn drop(ptr: usize)

impl<T> Read<Exclusive, BecauseExclusive> for PixelDensity where T: ?Sized,

impl<T> ToOwned for PixelDensity where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T, U> Into<U> for PixelDensity where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for PixelDensity where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for PixelDensity where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>