Skip to main content

Crate glyphimg

Crate glyphimg 

Source
Expand description

This is a tool to transform images into Grids of ColoredGlyphs.

§Example

An image is processed by creating an ImageProcessingJob.

use glyphimg::image::Image;
use glyphimg::font::MonospaceFont;
use glyphimg::{ImageProcessingJob, BackgroundMode};

let image = Image::from_bytes(&img_bytes)?;
let font = MonospaceFont::from_bytes(font_bytes, 16)?;

let background_mode = BackgroundMode::Auto;

let job = ImageProcessingJob::new(
    &image,
    &font,
    "abcdefghijklmnopqrstuvwxyz", // the glyphs to choose from
    80, // the width, in glyphs, of the output grid
    background_mode,
    false, // whether to process the chunks in a random order
    None // extra parameters for the color clustering algorithm
).ok()?;

let result = job.run(false, 1);

Re-exports§

pub use crate::image::Color;

Modules§

font
Functionality for importing fonts into a format useable by glyphimg.
grid
Functionality related to the 2-D Grid data structure.
image
Functionality for importing images into a format fit for conversion into glyphs.

Structs§

ColoredGlyph
Represents a glyph with a specific foreground Color and possibly a background Color.
ImageProcessingJob
An image processing job.

Enums§

BackgroundMode
Affects how a ColoredGlyph’s background color is generated.
ProcessingError
An error that occurs during image processing.
ProcessingEvent
Represents an event that occured during the running of an ImageProcessingJob.

Type Aliases§

Listener
An object capable of receiving ProcessingEvents.