Go 语言

Go 语言教程 Go 语言环境安装 Go 语言结构 Go 语言基础语法 Go 语言数据类型 Go 语言变量 Go 语言常量 Go 语言运算符 Go 语言条件语句 Go 语言 if 语句 Go 语言 if...else 语句 Go 语言 if 语句嵌套 Go 语言 switch 语句 Go 语言 select 语句 Go 语言循环语句 Go 语言 for 循环 Go 语言循环嵌套 Go 语言 break 语句 Go 语言 continue 语句 Go 语言 goto 语句 Go 语言函数 Go 语言函数值传递值 Go 语言函数引用传递值 Go 语言函数作为值 Go 语言函数闭包 Go 语言函数方法 Go 语言变量作用域 Go 语言数组 Go 语言多维数组 Go 语言向函数传递数组 Go 语言指针 Go 语言指针数组 Go 语言指向指针的指针 Go 语言指针作为函数参数 Go 语言结构体 Go 语言切片(Slice) Go 语言范围(Range) Go 语言Map(集合) Go 语言递归函数 Go 语言类型转换 Go 语言接口 Go 错误处理 Go 语言开发工具Go 语言标准库

Go 语言标准库


package png

import "image/png"

png包实现了PNG图像的编解码。PNG格式参见:http://www.w3.org/TR/PNG/

Go语言标准库 >>


  • type FormatError
  • type UnsupportedError
  • func Decode(r io.Reader) (image.Image, error)
  • func DecodeConfig(r io.Reader) (image.Config, error)
  • func Encode(w io.Writer, m image.Image) error
  • type FormatError

    type FormatError string

    当输入流不是合法的png格式图像时,就会返回FormatError类型的错误。

    func (FormatError) Error

    func (e FormatError) Error() string

    type UnsupportedError

    type UnsupportedError string

    当输入流使用了合法但尚不支持的png特性的时候,就会返回UnsupportedError类型的错误。

    func (UnsupportedError) Error

    func (e UnsupportedError) Error() string

    func Decode

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

    从r读取一幅png格式的图像并解码返回该图像。图像的具体类型要看png文件的内容而定。

    func DecodeConfig

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

    返回PNG图像的色彩模型和尺寸;函数不会解码整个图像。

    func Encode

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

    将图像m以PNG格式写入w。任意图像类型都可以被编码,但image.NRGBA以外格式的图像可能会在编码时丢失一些图像信息。