Documentation ¶
Overview ¶
Package jpeg implements reading and writing JPEG files as planar YUV data.
Package jpeg implements reading and writing JPEG files as planar YUV data.
Index ¶
Constants ¶
const ( Y = 0 U = 1 V = 2 )
Planes
const AlignSize int = 16
The dimension multiple to which data buffers should be aligned.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CompressionParameters ¶
type CompressionParameters struct { Quality int // Desired JPEG quality, 0-99 Optimize bool // Whether to optimize the Huffman tables (slower) FastDCT bool // Use a faster, less accurate DCT (note: do not use for Quality > 90) }
CompressionParameters specifies which settings to use during Compression.
type DecompressionParameters ¶
type DecompressionParameters struct { TargetWidth int // Desired output width TargetHeight int // Desired output height FastDCT bool // Use a faster, less accurate DCT (note: do not use for Quality > 90) }
DecompressionParameters specifies which settings to use during decompression. TargetWidth, TargetHeight specify the minimum image dimensions required. The image will be downsampled if applicable.
type PixelFormat ¶
type PixelFormat int
PixelFormat represents a JPEG pixel format (either YUVxxx or Grayscale).
const ( Grayscale PixelFormat = iota YUV444 // 1x1 subsampling YUV422 // 2x2 subsampling YUV440 // 1x2 subsampling YUV420 // 2x2 subsampling )
Valid PixelFormats
type YUVImage ¶
type YUVImage struct {
Width, Height int
Format PixelFormat
Data [3][]byte
Stride [3]int
}
YUVImage represents a planar image. Data is stored in a raw array of bytes for each plane, with an explicit stride (instead of a multidimensional array). This should probably be replaced with image.YCbCr (which I didn't know existed...)
func ReadJPEG ¶
func ReadJPEG(src io.Reader, params DecompressionParameters) (img *YUVImage, err error)
ReadJPEG reads a JPEG file and returns a planar YUV image.