Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dict ¶ added in v0.6.0
type Dict struct { // Width is the width of the image in pixels. Width int // Height is the height of the image in pixels. Height int // ColorSpace is the color space in which image samples are specified. // It can be any type of color space except Pattern. ColorSpace color.Space // BitsPerComponent is the number of bits used to represent each color component. // The value must be 1, 2, 4, 8, or (from PDF 1.5) 16. BitsPerComponent int // Intent (optional) is the name of a color rendering intent to be used in rendering the image. Intent graphics.RenderingIntent // MaskImage (optional) determines which parts of the image are to be // painted. // // Only one of MaskImage or MaskColors may be specified. MaskImage *ImageMask // MaskColors (optional) is an array of colors used for color key masking. // When specified, image samples with colors falling within the defined ranges // will not be painted, allowing the background to show through (similar to // chroma-key/green screen effects). // // The array contains pairs of min/max values for each color component: // [min1, max1, min2, max2, ..., minN, maxN] where N is the number of color // components in the image's color space. Each value must be in the range // 0 to (2^BitsPerComponent - 1) and represents raw color values before // any Decode array processing. // // A pixel is masked if ALL of its color components fall within their // respective min/max ranges. // // Only one of MaskImage or MaskColors may be specified. MaskColors []uint16 // Decode (optional) is an array of numbers describing how to map image // samples into the range of values appropriate for the image's color // space. The slice must have twice the number of color components // required by ColorSpace. Decode []float64 // Interpolate indicates whether image interpolation should be performed by // a PDF processor. Interpolate bool // Alternates (optional) is an array of alternate image dictionaries for this image. Alternates []*Dict // Name is deprecated and should be left empty. // Only used in PDF 1.0 where it was the name used to reference the image // mask from within content streams. Name pdf.Name // Metadata (optional) is a metadata stream containing metadata for the image. Metadata *metadata.Stream // WriteData is a function that writes the image data to the provided writer. // The data should be written row by row, with each row containing // Width * ColorSpace.Channels() samples, each sample using BitsPerComponent bits. WriteData func(io.Writer) error }
func FromImage ¶ added in v0.6.0
FromImage creates a Dict from an image.Image. The ColorSpace and BitsPerComponent must be set appropriately for the image.
func FromImageWithMask ¶ added in v0.6.0
func FromImageWithMask(img image.Image, mask image.Image, colorSpace color.Space, bitsPerComponent int) *Dict
FromImageWithMask creates a Dict with an associated ImageMask from two image.Image objects.
type ImageMask ¶ added in v0.6.0
type ImageMask struct { // Width is the width of the image mask in pixels. Width int // Height is the height of the image mask in pixels. Height int // WriteData is a function that writes the mask data to the provided writer. // The data should be written as a continuous bit stream, with each row // starting at a new byte boundary. 0 = opaque, 1 = transparent. WriteData func(io.Writer) error // Interpolate enables edge smoothing for the mask to reduce jagged // appearance in low-resolution stencil masks. Interpolate bool // Alternates (optional) is an array of alternate image dictionaries for this image. Alternates []*ImageMask // Name is deprecated and should be left empty. // Only used in PDF 1.0 where it was the name used to reference the image // from within content streams. Name pdf.Name // Metadata (optional) is a metadata stream containing metadata for the image. Metadata *metadata.Stream }
func FromImageMask ¶ added in v0.6.0
FromImageMask creates an ImageMask from an image.Image. Only the alpha channel is used, with alpha values rounded to full opacity or full transparency.
type Indexed ¶ added in v0.6.0
Indexed represents an image with an indexed color space.
func NewIndexed ¶ added in v0.6.0
NewIndexed returns a new Indexed image of the given size.
func (*Indexed) Bounds ¶ added in v0.6.0
Bounds returns the image bounds. This implements the Image interface.
type PNG ¶
type PNG struct { Data image.Image // ColorSpace is the color space of the image. // If this is not set, the image will be embedded as a DeviceRGB image. ColorSpace color.Space }
PNG represents an image which is stored losslessly in the PDF file. The encoding is similar to the PNG format.
type PixelRow ¶ added in v0.6.0
type PixelRow struct {
// contains filtered or unexported fields
}
PixelRow is a helper for efficiently packing pixel data into bytes for PDF image streams. It handles arbitrary bits per pixel and packs them into a byte array.
func NewPixelRow ¶ added in v0.6.0
NewPixelRow creates a new PixelRow for packing image data. numElems is the number of elements (pixels * channels) in the row. bitsPerElem is the number of bits per element (1, 2, 4, 8, or 16).
func (*PixelRow) AppendBits ¶ added in v0.6.0
AppendBits appends the specified number of bits to the row. Only the low-order numBits bits of the value are used.