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: i32The device x of column 0, relative to the glyph’s snapped origin.
top: i32The device y of row 0, relative to the glyph’s snapped origin.
width: i32Columns.
height: i32Rows.
channels: Vec<u8>height * width * 3 gamma-adjusted coverages, row-major, [r, g, b]
per pixel.
Implementations§
Source§impl SubpixelBitmap
impl SubpixelBitmap
Sourcepub fn at(&self, x: i32, y: i32) -> [u8; 3]
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]);Sourcepub fn is_empty(&self) -> bool
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());