Help us shape the future of Go! Take the 2026 Go Developer Survey

qoi

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package qoi provides a bounded adapter around Karty's pinned QOI codec.

Index

Constants

View Source
const (
	Magic            = "qoif"
	ChannelsRGB      = uint8(3)
	ChannelsRGBA     = uint8(4)
	ColorspaceSRGB   = uint8(0)
	ColorspaceLinear = uint8(1)

	MaxEncodedBytes = asset.MaxTexturePixels*maximumBytesPerPixel + headerSize + endMarkerSize
)

Variables

View Source
var (
	ErrInvalid = errors.New("QOI data is invalid")
)

Functions

This section is empty.

Types

type Metadata

type Metadata struct {
	Width        uint32
	Height       uint32
	Channels     uint8
	Colorspace   uint8
	DecodedBytes uint64
}

Metadata describes validated QOI content and its bounded decoded cost.

func Decode

func Decode(encoded []byte) (metadata Metadata, decoded *image.NRGBA, err error)

Decode returns straight-alpha NRGBA pixels only after bounded preflight, allocation-free stream validation and complete dependency decoding. Panics from malformed dependency input are contained and reported as ErrInvalid.

func Encode

func Encode(source image.Image, options Options) (encoded []byte, metadata Metadata, err error)

Encode converts a bounded image into deterministic QOI and validates the complete output before returning it. Panics from custom image implementations or the dependency are contained and reported as ErrInvalid.

func Inspect

func Inspect(encoded []byte) (Metadata, error)

Inspect validates a QOI header, resource bounds, and the exact end marker without allocating decoded pixels. Decode performs complete stream validation.

func Validate added in v0.0.8

func Validate(encoded []byte) (Metadata, error)

Validate checks header bounds and the complete stream without allocating decoded pixels. Its metadata can be used to preflight a shared image budget.

type Options

type Options struct {
	Channels   uint8
	Colorspace uint8
}

Options selects QOI header metadata. It does not change pixel encoding.

Jump to

Keyboard shortcuts

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