ico

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2024 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package ico implements a minimal ICO image decoder

References: - http://www.digicamsoft.com/bmp/bmp.html - https://en.wikipedia.org/wiki/ICO_(file_format)

Note: - DecodeConfig is not implemented

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

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

func DecodeConfig

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

Types

type BitmapFileHeader

type BitmapFileHeader struct {
	Type       [2]byte // The header field used to identify the BMP and DIB file is 0x42 0x4D in hexadecimal, same as BM in ASCII.
	Size       uint32  // The size of the BMP file in bytes
	Reserved1  uint16  // Reserved; actual value depends on the application that creates the image, if created manually can be 0
	Reserved2  uint16  // Reserved; actual value depends on the application that creates the image, if created manually can be 0
	OffsetBits uint32  // The offset, i.e. starting address, of the byte where the bitmap image data (pixel array) can be found.
}

BitmapFileHeader represents the Bitmap File Header structure

type BitmapInfoHeader

type BitmapInfoHeader struct {
	Size     uint32 // the size of this header, in bytes (40)
	Width    int32  // the bitmap width in pixels (signed integer)
	Height   int32  // the bitmap width in pixels (signed integer)
	Planes   uint16 // the number of color planes (must be 1)
	BitCount uint16 // the number of bits per pixel, which is the color depth of the image. Typical values are 1, 4, 8, 16, 24 and 32.
	// Note for ico files the fields below can be zero
	Compression     uint32 // the compression method being used. See the next table for a list of possible values
	SizeImage       uint32 // the image size. This is the size of the raw bitmap data; a dummy 0 can be given for BI_RGB bitmaps.
	XPixelsPerMeter int32  // the horizontal resolution of the image. (pixel per metre, signed integer)
	YPixelsPerMeter int32  // the vertical resolution of the image. (pixel per metre, signed integer)
	ColorsUsed      uint32 // the number of colors in the color palette, or 0 to default to 2n
	ColorsImportant uint8  // the number of important colors used, or 0 when every color is important; generally ignored
}

BitmapInfoHeader represents the Bitmap Info Header structure

type IconDirectoryEntry

type IconDirectoryEntry struct {
	Width       uint8  // Specifies image width in pixels. Can be any number between 0 and 255. Value 0 means image width is 256 pixels.
	Height      uint8  // Specifies image height in pixels. Can be any number between 0 and 255. Value 0 means image height is 256 pixels.
	ColorCount  uint8  // Specifies number of colors in the color palette. Should be 0 if the image does not use a color palette.
	Reserved    uint8  // Reserved. Should be 0
	Planes      uint16 // Specifies color planes. Should be 0 or 1.
	BitCount    uint16 // Specifies bits per pixel.
	BytesInRes  uint32 // Specifies the size of the image's data in bytes.
	ImageOffset uint32 // Specifies the offset of BMP or PNG data from the beginning of the ICO/CUR file
}

IconDirectoryEntry represents the Icon Directory Entry structure

type IconHeader

type IconHeader struct {
	Reserved uint16 // Reserved. Must always be 0.
	Type     uint16 // Specifies image type: 1 for icon (.ICO) image, 2 for cursor (.CUR) image. Other values are invalid.
	Count    uint16 // Specifies the number of iconDirectoryEntry
}

IconHeader represents the Icon Directory Header structure

Jump to

Keyboard shortcuts

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