dib

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package dib decodes the shared Windows DIB pixel representation used by BMP and ICO. Container headers, icon selection and icon AND masks live elsewhere.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeConfig added in v0.5.5

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

DecodeConfig reads the DIB header, masks and indexed palette using the same validation as Decode. It never reads or allocates decoded raster data.

func Stride

func Stride(width, depth int) (int, error)

Stride returns a DWORD-aligned scanline size after checked arithmetic.

Types

type Options

type Options struct {
	// PixelOffset is relative to the beginning of the DIB. Zero means pixels
	// immediately follow the header, masks and palette (packed DIBs in ICO).
	PixelOffset int
	// IconSize requests ICO's positive doubled header height and legacy BGRA
	// interpretation of BI_RGB/32. A zero point means an ordinary bitmap.
	IconSize image.Point
}

Options makes container-specific interpretation explicit.

type Result

type Result struct {
	Image    image.Image
	BitCount uint16
	// PixelEnd is the byte offset after the XOR/color data, relative to the DIB.
	PixelEnd int
	// LegacyAlpha allows ICO's all-zero-alpha fallback only for BI_RGB/32.
	LegacyAlpha bool
}

func Decode

func Decode(data []byte, opts Options) (*Result, error)

Decode validates the DIB before allocating its output image. Indexed data is returned as image.Paletted, direct color as image.NRGBA.

Jump to

Keyboard shortcuts

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