Package png

import "image/png"
Overview
Index
Examples

Overview ▾

png包实现了PNG图像解码器和编码器.

PNG规范位于https://www.w3.org/TR/PNG/ .

func Decode

func Decode(r io.Reader) (image.Image, error)

解码从r读取PNG图片,并将其作为image.Image返回. 返回的图像类型取决于PNG内容.

Example

func DecodeConfig

func DecodeConfig(r io.Reader) (image.Config, error)

DecodeConfig返回PNG图像的颜色模型和尺寸,而无需解码整个图像.

func Encode

func Encode(w io.Writer, m image.Image) error

编码将图像m以PNG格式写入w. 可以对任何图像进行编码,但对不是图像的图像进行编码.NRGBA可能会进行有损编码.

Example

type CompressionLevel 1.4

type CompressionLevel int
const (
    DefaultCompression CompressionLevel = 0
    NoCompression      CompressionLevel = -1
    BestSpeed          CompressionLevel = -2
    BestCompression    CompressionLevel = -3
)

type Encoder 1.4

编码器配置编码PNG图像.

type Encoder struct {
    CompressionLevel CompressionLevel

    // BufferPool optionally specifies a buffer pool to get temporary
    // EncoderBuffers when encoding an image.
    BufferPool EncoderBufferPool // Go 1.9
}

func (*Encoder) Encode 1.4

func (enc *Encoder) Encode(w io.Writer, m image.Image) error

编码将图像m以PNG格式写入w.

type EncoderBuffer 1.9

EncoderBuffer保存用于编码PNG图像的缓冲区.

type EncoderBuffer encoder

type EncoderBufferPool 1.9

EncoderBufferPool是用于获取和返回EncoderBuffer结构的临时实例的接口. 编码多个图像时,可用于重用缓冲区.

type EncoderBufferPool interface {
    Get() *EncoderBuffer
    Put(*EncoderBuffer)
}

type FormatError

FormatError报告输入不是有效的PNG.

type FormatError string

func (FormatError) Error

func (e FormatError) Error() string

type UnsupportedError

UnsupportedError报告输入使用了有效但未实现的PNG功能.

type UnsupportedError string

func (UnsupportedError) Error

func (e UnsupportedError) Error() string

by  ICOPY.SITE