Documentation ¶
Overview ¶
Package jpeg decodes JPEG image to image.YCbCr using libjpeg (or libjpeg-turbo).
Package rgb provides RGB image which implements image.Image interface.
Index ¶
- Constants
- Variables
- func Decode(r io.Reader, options *DecoderOptions) (dest image.Image, err error)
- func DecodeConfig(r io.Reader) (config image.Config, err error)
- func DecodeIntoRGBA(r io.Reader, options *DecoderOptions) (dest *image.RGBA, err error)
- func Encode(w io.Writer, src image.Image, opt *EncoderOptions) error
- func EncodeToBytes(src image.Image, opt *EncoderOptions) ([]byte, error)
- func NewGrayAligned(r image.Rectangle) *image.Gray
- func NewYCbCrAligned(r image.Rectangle, subsampleRatio image.YCbCrSubsampleRatio) *image.YCbCr
- func SourceManagerMapLen() int
- func SupportRGBA() bool
- type DCTMethod
- type DecoderOptions
- type EncoderOptions
- type RGB
- type RGBImage
Constants ¶
const ( Y = 0 Cb = 1 Cr = 2 )
Y/Cb/Cr Planes
Variables ¶
var ColorModel = color.ModelFunc(rgbModel)
ColorModel is RGB color model instance
Functions ¶
func Decode ¶
Decode reads a JPEG data stream from r and returns decoded image as an image.Image. Output image has YCbCr colors or 8bit Grayscale.
func DecodeConfig ¶
DecodeConfig returns the color model and dimensions of a JPEG image without decoding the entire image.
func DecodeIntoRGBA ¶
DecodeIntoRGBA reads a JPEG data stream from r and returns decoded image as an image.RGBA with RGBA colors. This function only works with libjpeg-turbo, not libjpeg.
func EncodeToBytes ¶
func EncodeToBytes(src image.Image, opt *EncoderOptions) ([]byte, error)
Encode encodes src image and returns the JPEG encoded bytes.
func NewGrayAligned ¶
NewGrayAligned Allocates Grey image with padding. This func add an extra padding to cover overflow from decoding image.
func NewYCbCrAligned ¶
NewYCbCrAligned Allocates YCbCr image with padding. Because LibJPEG needs extra padding to decoding buffer, This func add an extra alignSize (16) padding to cover overflow from any such modes.
func SourceManagerMapLen ¶
func SourceManagerMapLen() int
SourceManagerMapLen returns the number of globally working sourceManagers for debug.
Types ¶
type DCTMethod ¶
type DCTMethod C.J_DCT_METHOD
DCTMethod is the DCT/IDCT method type.
const ( // DCTISlow is slow but accurate integer algorithm DCTISlow DCTMethod = C.JDCT_ISLOW // DCTIFast is faster, less accurate integer method DCTIFast DCTMethod = C.JDCT_IFAST // DCTFloat is floating-point: accurate, fast on fast HW DCTFloat DCTMethod = C.JDCT_FLOAT )
type DecoderOptions ¶
type DecoderOptions struct { ScaleTarget image.Rectangle // ScaleTarget is the target size to scale image. DCTMethod DCTMethod // DCTMethod is DCT Algorithm method. DisableFancyUpsampling bool // If true, disable fancy upsampling DisableBlockSmoothing bool // If true, disable block smoothing }
DecoderOptions specifies JPEG decoding parameters.
type EncoderOptions ¶
type EncoderOptions struct { Quality int OptimizeCoding bool ProgressiveMode bool DCTMethod DCTMethod }
EncoderOptions specifies which settings to use during Compression.
type RGBImage ¶
type RGBImage struct { // Pix holds the image's stream, in R, G, B order. Pix []uint8 // Stride is the Pix stride (in bytes) between vertically adjacent pixels. Stride int // Rect is the image's bounds. Rect image.Rectangle }
RGBImage represent image data which has RGB colors. RGBImage is compatible with image.RGBA, but does not have alpha channel to reduce using memory.
func DecodeIntoRGB ¶
func DecodeIntoRGB(r io.Reader, options *DecoderOptions) (dest *RGBImage, err error)
DecodeIntoRGB reads a JPEG data stream from r and returns decoded image as an rgb.Image with RGB colors.
func NewRGBImage ¶
NewRGBImage allocates and returns RGB image
func (*RGBImage) ColorModel ¶
ColorModel returns RGB color model.