/** * Helper functions for getting images printed. * * @experimental * @module */ import type { ImageData, ImageDataArray } from './dom.js'; /** A minimal form of the DOM's {@link ImageData}. */ export type EposImageData = ImageData | { readonly width: number; readonly height: number; readonly data: ImageDataArray | Uint8Array; } | { width: number; height: number; data: ImageDataArray | Uint8Array; }; /** How the image encoder should handle halftone stuff. */ export declare enum EposImageHalftone { Dither = 0, ErrorDiffusion = 1, Threshold = 2 } /** Converts the image to a monochrome printer imagedata. */ export declare const toMonoImage: (img: EposImageData, halftone: EposImageHalftone, brightness: number) => Uint8Array; /** Converts the image to a grayscale printer imagedata. Only for supported models */ export declare const toGrayImage: (img: EposImageData, brightness: number) => Uint8Array; /** * A pure JS Uint8Array Base64 encoder. You should probably use {@link utoa} instead. * * Based on {@link https://stackoverflow.com/a/62362724 Stackoverflow: How to convert uint8 Array to base64 Encoded String?} * * Dependencies: * - {@link number} * - {@link Number.prototype.length} * - {@link Number.prototype.toString} * - {@link string} * - {@link String.prototype.startsWith} * - {@link String.prototype.match} * - {@link String.prototype.map} * - {@link RegExp} * - {@link undefined} * - {@link Error} (optional) * - {@link JSON.stringify} (optional, for error message) * * @param alphabet The base64 alphabet to use * @param padding The character to use for padding */ export declare const rawUtoa: (u8: Uint8Array, alphabet?: string, padding?: string) => string; /** * Uint8Array to Ascii. Similar to {@link btoa}, but safer. * * Internally, this first attempts to call {@link Uint8Array.prototype.toBase64}, * if it is available in the runtime ({@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array/toBase64#browser_compatibility caniuse}). * * Due to our minimum deno version being 2.3.1 (Alpine 3.23.3 Stable), * which doesn't implement it (was added in 2.5), we need to fallback if needed. * If it isn't installed, we fallback to, if {@link btoa} and {@link TextDecoder} * are both available, trying to use {@link btoa} on the result of * {@link TextDecoder.prototype.decode}. * * Should {@link TextDecoder} be unavailable or error (likely for some binary * data), we attempt to call {@link btoa} with our own text decoder based on * {@link String.fromCharCode}. This too can fail on some binary outputs. * * Should this too fail, or should {@link btoa} not be available, we use * {@link https://stackoverflow.com/a/62362724 this implementation from stackoverflow}, * exposed as {@link rawUtoa}. */ export declare const utoa: (u8: Uint8Array) => string; //# sourceMappingURL=epos-image-helpers.d.ts.map