Skip to main content

SubpixelBitmap

Struct SubpixelBitmap 

Source
pub struct SubpixelBitmap {
    pub left: i32,
    pub top: i32,
    pub width: i32,
    pub height: i32,
    pub channels: Vec<u8>,
}
Expand description

One glyph rasterized to three coverages per pixel — one per LCD stripe.

The same bitmap GlyphBitmap holds, with the 3× subpixel triples kept apart instead of averaged. It is produced for exactly one kind of text on a page: a live edit’s, which is drawn with ClearType on while the rest of the page is not.

The three bytes are the destination’s red, green and blue coverages in that order — the oracle assumes RGB-ordered stripes, mapping the leftmost subpixel to red. Each is gamma-adjusted and merged into its own destination channel independently, which is what puts colour on the fringes of a glyph drawn in a single colour.

use pdfrum_render::glyph::SubpixelBitmap;

let bitmap = SubpixelBitmap {
    left: 0,
    top: 0,
    width: 2,
    height: 1,
    channels: vec![255, 0, 0, 0, 0, 0],
};

// The three bytes are the destination's red, green and blue
// coverages, each merged into its own channel.
assert_eq!(bitmap.at(0, 0), [255, 0, 0]);

Fields§

§left: i32

The device x of column 0, relative to the glyph’s snapped origin.

§top: i32

The device y of row 0, relative to the glyph’s snapped origin.

§width: i32

Columns.

§height: i32

Rows.

§channels: Vec<u8>

height * width * 3 gamma-adjusted coverages, row-major, [r, g, b] per pixel.

Implementations§

Source§

impl SubpixelBitmap

Source

pub fn at(&self, x: i32, y: i32) -> [u8; 3]

The [r, g, b] coverages at (x, y), or zeroes outside the bitmap.

use pdfrum_render::glyph::SubpixelBitmap;

let bitmap = SubpixelBitmap {
    left: 0,
    top: 0,
    width: 2,
    height: 1,
    channels: vec![255, 0, 0, 0, 0, 0],
};

assert_eq!(bitmap.at(1, 0), [0, 0, 0]);
// Outside the bitmap is zeroes, not a panic.
assert_eq!(bitmap.at(-1, 0), [0, 0, 0]);
assert_eq!(bitmap.at(9, 9), [0, 0, 0]);
Source

pub fn is_empty(&self) -> bool

Whether the bitmap has no pixels at all, which a blank glyph produces.

use pdfrum_render::glyph::SubpixelBitmap;

let bitmap = SubpixelBitmap {
    left: 0,
    top: 0,
    width: 2,
    height: 1,
    channels: vec![255, 0, 0, 0, 0, 0],
};

assert!(!bitmap.is_empty());
// What a blank glyph produces.
let blank = SubpixelBitmap { width: 0, height: 0, ..bitmap };
assert!(blank.is_empty());

Trait Implementations§

Source§

impl Clone for SubpixelBitmap

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SubpixelBitmap

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for SubpixelBitmap

Source§

impl PartialEq for SubpixelBitmap

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SubpixelBitmap

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

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

Source§

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.