Documentation
¶
Overview ¶
Package screentone prepares comic and manga page images for display on e-ink devices: fitting to a panel's resolution, tone correction for its contrast characteristics, spread splitting, and optional quantization to its native grey levels.
The same input and options always produce the same output bytes; the pipeline uses no clocks, randomness, or iteration-order-dependent state.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( Elipsa = Profile{Name: "elipsa", Width: 1404, Height: 1872, Levels: 16, Gamma: 1.0} ClaraHD = Profile{Name: "clara-hd", Width: 1072, Height: 1448, Levels: 16, Gamma: 1.0} Libra2 = Profile{Name: "libra-2", Width: 1264, Height: 1680, Levels: 16, Gamma: 1.0} Sage = Profile{Name: "sage", Width: 1440, Height: 1920, Levels: 16, Gamma: 1.0} )
Shipped profiles. Elipsa is the primary target; the others are secondary and untested on hardware.
Functions ¶
func EncodeJPEG ¶
EncodeJPEG writes img as a baseline greyscale JPEG. Non-Gray images are converted first. quality is 1–100 (85 is a good default).
Types ¶
type Option ¶
type Option func(*config)
Option adjusts Process behavior.
func WithDither ¶
func WithDither() Option
WithDither reduces output to the profile's grey levels with Floyd–Steinberg error diffusion. Implies quantization.
func WithQuantize ¶
func WithQuantize() Option
WithQuantize reduces output to the profile's grey levels by nearest-level thresholding.
func WithSpreadPolicy ¶
func WithSpreadPolicy(sp SpreadPolicy) Option
WithSpreadPolicy sets how landscape spreads are handled.
func WithTrimTolerance ¶
WithTrimTolerance sets how many luminance levels a pixel must differ from the background to count as content (default 16).
func WithoutAutoContrast ¶
func WithoutAutoContrast() Option
WithoutAutoContrast disables the histogram stretch.
func WithoutResize ¶
func WithoutResize() Option
WithoutResize disables fitting to the panel resolution.
func WithoutUpscale ¶
func WithoutUpscale() Option
WithoutUpscale passes pages smaller than the panel through at original size instead of scaling them up.
type Profile ¶
type Profile struct {
Name string // stable identifier, e.g. "elipsa"
Width int // panel width in pixels, portrait orientation
Height int // panel height in pixels, portrait orientation
Levels int // native grey levels, e.g. 16
Gamma float64 // default gamma correction; 1.0 = none
}
Profile bundles an e-ink panel's geometry and tuning.
type SpreadPolicy ¶
type SpreadPolicy int
SpreadPolicy selects how landscape (double-page) images are handled.
const ( // SplitRTL splits a spread at the vertical midline, right half first // (manga reading order). The default. SplitRTL SpreadPolicy = iota // SplitLTR splits a spread at the vertical midline, left half first. SplitLTR // Preserve passes a spread through unsplit, marked KindSpread. Preserve )