ico

package
v0.0.0-...-0b57644 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 3, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// 错误信息
	ErrIcoInvalid  = errors.New("ico: Invalid icon file")                   // 无效的ico文件
	ErrIcoReaders  = errors.New("ico: Reader type is not os.File pointer")  // LoadIconFile的io.Reader参数不是文件指针
	ErrIcoFileType = errors.New("ico: Reader is directory, not file")       // io.Reader的文件指针是目录,不是文件
	ErrIconsIndex  = errors.New("ico: Slice out of bounds")                 // 读取ico文件时,可能出现的切片越界错误
	PNGHEADER      = []byte{0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A} // PNG 文件头
	DIBHEADER      = []byte{0x28, 0, 0, 0}                                  // DIB 头
	BMPHEADERID    = []byte{0x42, 0x4d}
)

定义变量 Variable definitions

Functions

This section is empty.

Types

type ICONTYPE

type ICONTYPE int

类型定义 type definition 定义icon图标数据的类型 Define the type of icon data

func GetIconType

func GetIconType(d []byte) ICONTYPE

GetIconType 获取icon的数据类型 Get the image type of the icon

type WinIcon

type WinIcon struct {
	// contains filtered or unexported fields
}

定义 Windows 系统的 Ico 文件结构 Defining the Ico file structure of Windows system

func CreateWinIcon

func CreateWinIcon(filePath []string) (*WinIcon, error)

CreateWinIcon 可以将N个BMP和PNG图像打包为一 个windows系统的ico文件所需要的结构 BMP和PNG目前不支持压缩过及带调色板的索引图像 filePath []string: 文件的路径 成功返回 WinIcon 对象的指针 失败返回 error 对象 The structure required to package n's BMP and PNG images into a ico file of windows system filePath []string: bmp or png file path string array(slice) a pointer to a WinIcon object that successfully returns. Failed to return error object

func LoadIconFile

func LoadIconFile(rd io.Reader) (icon *WinIcon, err error)

将ico文件的数据载入到内存 Load data from ico file into memory rd io.Reader must *os.File object pointer. Successfully return WinIcon pointer. Failed to return error object

func (*WinIcon) ExtractIconToFile

func (wi *WinIcon) ExtractIconToFile(filePrefix, filePath string) error

ExtractIconToFile 提取 ico 数据到文件 filePrefix string: 为前缀,如果传如空字符串,则没有前缀,使用数字和分辨率作为文件名 filePath string: 提取的数据写入的路径,空字符串则将文件保存到当前目录 舍弃:--count int: 提取文件的数量,0: 为所有,> 0 则根据已保存的map对象来提取 对应数量内容,指定数量超出实际数量则全部提取-- 该函数不检测路径的有效性,使用者自己把控,如果路径有问题,会返回error对象 ExtractIconToFile function its extract ico data to file(.ico) The prefix, if passed as an empty string, there is no prefix, using the number and resolution as the file name. This function does not detect the validity of the path. the user controls it. if there is a problem with the path, it will return an error object.

func (*WinIcon) GetImageData

func (wi *WinIcon) GetImageData(index int) (d []byte, err error)

GetImageData 获取ico图标的图像数据 index int: 下标索引,0序 如果越界或读取数据错误,返回 error 对象 Returns an error object if it is out of bounds or reads data incorrectly.

func (*WinIcon) IconToFile

func (wi *WinIcon) IconToFile(path, name string, index int) error

IconToFile 将图标写入文件 path string: 文件写入的路径 name string: 文件名 error 如果写入发生错误,则返回错误信息 IconToFile 并不会检测路径是否有效 write icon to file. path argument its file path(no check legality)

func (*WinIcon) IconToIcoFile

func (wi *WinIcon) IconToIcoFile(path string, index int) error

IconToIcoFile 将ico文件中的指定icon图标数据写入ico文件 path string: 路径(不检查合法性) index int: icon图标的索引 error: 如果发生错误返回error对象 Write the specified icon data in the ico file to the ico file. path argument its path of file write(no check legality)

func (*WinIcon) WriteIcoFile

func (wi *WinIcon) WriteIcoFile(filePath, fileName string)

WriteIcoFile 将icon图标打包数据写入磁盘文件

type WinIconData

type WinIconData []byte

类型定义 type definition 定义icon图标数据的类型 Define the type of icon data

type WinIconStruct

type WinIconStruct []winIconStruct

类型定义 type definition 定义icon图标数据的类型 Define the type of icon data

func (WinIconStruct) Len

func (w WinIconStruct) Len() int

Len 实现go语言的排序算法接口中Len方法 Implementing the Go language sorting algorithm interface in the Len method

func (WinIconStruct) Less

func (w WinIconStruct) Less(i, j int) bool

Less 实现go语言的排序算法接口中Less方法 Implementing the go language sorting algorithm interface in the Less method

func (WinIconStruct) Swap

func (w WinIconStruct) Swap(i, j int)

Swap 实现go语言的排序算法接口中的Swap方法 Implementing the go language sorting algorithm interface in the Swap method

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL