Documentation
¶
Overview ¶
Package rowenc writes PNG and TIFF files from the rows of an image as they come, for an image drawn in bands (imagebdf.PageRows) that is not all in memory at once: a page at 600 dpi is written with the memory of a band of it and of the compression.
A Writer is made for an image of a width, height and Kind, takes the rows in order with WriteRows, and is closed. The files decode (with image/png and a TIFF reader) to the pixels given: the PNG of an RGBA image is written as image/png writes an *image.RGBA, in colour type RGBA with the alpha unmultiplied, whether or not the image is opaque, since the rows to come are not known.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Kind ¶
type Kind int
Kind is the pixels of an image written.
const ( // RGBA is 8 bits a channel with premultiplied alpha, as *image.RGBA // holds them: the PNG is of colour type RGBA (the alpha unmultiplied, // as image/png writes it), the TIFF of RGB with an associated alpha // sample. RGBA Kind = iota // Gray is 8 bits a pixel, as *image.Gray. Gray // Bilevel is a bit a pixel, black and white: the rows are an // *image.Paletted of two colours, black first (as imagebdf.Bilevel // draws them), or an *image.Gray whose values below 128 are black. // The PNG is of a palette of the two colours at a bit a pixel, the // TIFF of a bit a pixel with 0 black (min-is-black). Bilevel )
type Options ¶
type Options struct {
// Level is the zlib compression level of a PNG, from 1 (fastest) to
// 9 (smallest), as compress/flate numbers them; 0 is the default
// level (6). A TIFF is not compressed.
Level int
// DPI is the resolution noted in the file: the pHYs chunk of a PNG
// and the resolution tags of a TIFF. Zero notes none in a PNG and 72
// in a TIFF.
DPI float64
// Threads is how many goroutines filter and compress the rows of a
// PNG, in chunks of rows: zero uses those of the machine, up to
// eight. The file is the same whatever the number.
Threads int
}
Options configures a Writer.
type PNG ¶
type PNG struct {
// contains filtered or unexported fields
}
PNG writes a PNG file from the rows of an image (see Writer).
The rows are filtered and compressed in chunks of a fixed number of rows, each by a goroutine (see Options.Threads): the deflate stream of the image is the streams of the chunks one after the other, each ended with a sync flush, so the file is the same however the rows come and however many goroutines write it.
type TIFF ¶
type TIFF struct {
// contains filtered or unexported fields
}
TIFF writes a TIFF file from the rows of an image (see Writer): not compressed, in one strip, with the directory before the pixels, so that the file is written in order without seeking. The pixels are 8 bits a sample (RGB with an associated alpha sample for RGBA, gray), or a bit a pixel with 0 black for Bilevel.
func NewTIFF ¶
NewTIFF returns a writer of a TIFF file of width × height pixels of a kind to w (see Options; the compression level does not apply).
type Writer ¶
type Writer interface {
// WriteRows writes the next rows: an image as wide as the one
// written, of the kind of the writer (see Kind), whose rows follow
// those written before. Its bounds may start anywhere.
WriteRows(rows image.Image) error
// Close writes what ends the file and reports an error if the rows
// written are not all of the image.
Close() error
}
Writer writes an image from its rows, from the top.