#[repr(transparent)]pub struct DevicePixels(pub i32);Expand description
Represents physical pixels on the display.
DevicePixels is a unit of measurement that refers to the actual pixels on a device’s screen.
This type is used when precise pixel manipulation is required, such as rendering graphics or
interfacing with hardware that operates on the pixel level. Unlike logical pixels that may be
affected by the device’s scale factor, DevicePixels always correspond to real pixels on the
display.
Tuple Fields§
§0: i32Implementations§
Source§impl DevicePixels
impl DevicePixels
Sourcepub fn to_bytes(self, bytes_per_pixel: u8) -> u32
pub fn to_bytes(self, bytes_per_pixel: u8) -> u32
Converts the DevicePixels value to the number of bytes needed to represent it in memory.
This function is useful when working with graphical data that needs to be stored in a buffer, such as images or framebuffers, where each pixel may be represented by a specific number of bytes.
§Arguments
bytes_per_pixel- The number of bytes used to represent a single pixel.
§Returns
The number of bytes required to represent the DevicePixels value in memory.
§Examples
let pixels = DevicePixels(10); // 10 device pixels
let bytes_per_pixel = 4; // Assume each pixel is represented by 4 bytes (e.g., RGBA)
let total_bytes = pixels.to_bytes(bytes_per_pixel);
assert_eq!(total_bytes, 40); // 10 pixels * 4 bytes/pixel = 40 bytesTrait Implementations§
Source§impl Add for DevicePixels
impl Add for DevicePixels
Source§type Output = DevicePixels
type Output = DevicePixels
+ operator.Source§fn add(self, rhs: DevicePixels) -> DevicePixels
fn add(self, rhs: DevicePixels) -> DevicePixels
+ operation. Read moreSource§impl AddAssign for DevicePixels
impl AddAssign for DevicePixels
Source§fn add_assign(&mut self, rhs: DevicePixels)
fn add_assign(&mut self, rhs: DevicePixels)
+= operation. Read moreSource§impl Clone for DevicePixels
impl Clone for DevicePixels
Source§fn clone(&self) -> DevicePixels
fn clone(&self) -> DevicePixels
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DevicePixels
impl Debug for DevicePixels
Source§impl Default for DevicePixels
impl Default for DevicePixels
Source§fn default() -> DevicePixels
fn default() -> DevicePixels
Source§impl<'de> Deserialize<'de> for DevicePixels
impl<'de> Deserialize<'de> for DevicePixels
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<__RhsT> Div<__RhsT> for DevicePixels
impl<__RhsT> Div<__RhsT> for DevicePixels
Source§type Output = DevicePixels
type Output = DevicePixels
/ operator.Source§fn div(self, rhs: __RhsT) -> DevicePixels
fn div(self, rhs: __RhsT) -> DevicePixels
/ operation. Read moreSource§impl From<DevicePixels> for ScaledPixels
impl From<DevicePixels> for ScaledPixels
Source§fn from(device: DevicePixels) -> Self
fn from(device: DevicePixels) -> Self
Source§impl From<DevicePixels> for i32
impl From<DevicePixels> for i32
Source§fn from(device_pixels: DevicePixels) -> Self
fn from(device_pixels: DevicePixels) -> Self
Source§impl From<DevicePixels> for u32
impl From<DevicePixels> for u32
Source§fn from(device_pixels: DevicePixels) -> Self
fn from(device_pixels: DevicePixels) -> Self
Source§impl From<DevicePixels> for u64
impl From<DevicePixels> for u64
Source§fn from(device_pixels: DevicePixels) -> Self
fn from(device_pixels: DevicePixels) -> Self
Source§impl From<DevicePixels> for usize
impl From<DevicePixels> for usize
Source§fn from(device_pixels: DevicePixels) -> Self
fn from(device_pixels: DevicePixels) -> Self
Source§impl From<ScaledPixels> for DevicePixels
impl From<ScaledPixels> for DevicePixels
Source§fn from(scaled: ScaledPixels) -> Self
fn from(scaled: ScaledPixels) -> Self
Source§impl From<i32> for DevicePixels
impl From<i32> for DevicePixels
Source§impl From<u32> for DevicePixels
impl From<u32> for DevicePixels
Source§impl From<u64> for DevicePixels
impl From<u64> for DevicePixels
Source§impl From<usize> for DevicePixels
impl From<usize> for DevicePixels
Source§impl Half for DevicePixels
impl Half for DevicePixels
Source§impl Hash for DevicePixels
impl Hash for DevicePixels
Source§impl IsZero for DevicePixels
impl IsZero for DevicePixels
Source§impl Negate for DevicePixels
impl Negate for DevicePixels
Source§impl Ord for DevicePixels
impl Ord for DevicePixels
Source§fn cmp(&self, other: &DevicePixels) -> Ordering
fn cmp(&self, other: &DevicePixels) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for DevicePixels
impl PartialEq for DevicePixels
Source§impl PartialOrd for DevicePixels
impl PartialOrd for DevicePixels
Source§impl Serialize for DevicePixels
impl Serialize for DevicePixels
Source§impl Sub for DevicePixels
impl Sub for DevicePixels
Source§type Output = DevicePixels
type Output = DevicePixels
- operator.Source§fn sub(self, rhs: DevicePixels) -> DevicePixels
fn sub(self, rhs: DevicePixels) -> DevicePixels
- operation. Read moreSource§impl SubAssign for DevicePixels
impl SubAssign for DevicePixels
Source§fn sub_assign(&mut self, rhs: DevicePixels)
fn sub_assign(&mut self, rhs: DevicePixels)
-= operation. Read moreimpl Copy for DevicePixels
impl Eq for DevicePixels
impl StructuralPartialEq for DevicePixels
Auto Trait Implementations§
impl Freeze for DevicePixels
impl RefUnwindSafe for DevicePixels
impl Send for DevicePixels
impl Sync for DevicePixels
impl Unpin for DevicePixels
impl UnwindSafe for DevicePixels
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<K> MapSeekTarget<K> for Kwhere
K: Ord,
impl<K> MapSeekTarget<K> for Kwhere
K: Ord,
fn cmp_cursor(&self, cursor_location: &K) -> Ordering
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().