ico

package module
v1.0.0-beta.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2024 License: BSD-3-Clause Imports: 3 Imported by: 0

README

ico

tests Go Reference Go Report Card codecov

Package ico implements an ICO file decoder and encoder. Package cur implements a CUR file decoder and encoder.

See https://en.wikipedia.org/wiki/ICO_(file_format) for more information.

Installation

Use go get:

go get github.com/sergeymakinen/go-ico

Then import the package into your own code:

import "github.com/sergeymakinen/go-ico"

Example

b, _ := os.ReadFile("icon_32x32-32.png")
m1, _ := png.Decode(bytes.NewReader(b))
b, _ = os.ReadFile("icon_256x256-32.png")
m2, _ := png.Decode(bytes.NewReader(b))
f, _ := os.Create("icon.ico")
ico.EncodeAll(f, []image.Image{m1, m2})
f.Close()

License

BSD 3-Clause

Documentation

Overview

Package ico implements an ICO file decoder and encoder.

Example
b, _ := os.ReadFile("icon_32x32-32.png")
m1, _ := png.Decode(bytes.NewReader(b))
b, _ = os.ReadFile("icon_256x256-32.png")
m2, _ := png.Decode(bytes.NewReader(b))
f, _ := os.Create("icon.ico")
ico.EncodeAll(f, []image.Image{m1, m2})
f.Close()
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

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

Decode reads an ICO image from r and returns the largest stored icon as an image.Image.

func DecodeAll

func DecodeAll(r io.Reader) ([]image.Image, error)

DecodeAll reads an ICO image from r and returns the stored icons.

func DecodeConfig

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

DecodeConfig returns the color model and dimensions of the largest icon stored in an ICO image without decoding the entire icon.

func Encode

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

Encode writes the icon m to w in ICO format.

func EncodeAll

func EncodeAll(w io.Writer, mm []image.Image) error

EncodeAll writes the icons in mm to w in ICO format.

Types

type FormatError

type FormatError string

FormatError reports that the input is not a valid ICO.

func (FormatError) Error

func (e FormatError) Error() string

type UnsupportedError

type UnsupportedError string

UnsupportedError reports that the input uses a valid but unimplemented ICO feature.

func (UnsupportedError) Error

func (e UnsupportedError) Error() string

Directories

Path Synopsis
Package cur implements a CUR file decoder and encoder.
Package cur implements a CUR file decoder and encoder.
internal

Jump to

Keyboard shortcuts

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