qoi

package module
v0.0.0-...-8956436 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2025 License: MIT Imports: 12 Imported by: 1

README

QOI

It's QOI. The Quite Ok Image format. Implemented in a (hopefully) simple and easy to understand way.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ColorHash

func ColorHash(pixel Pixel) uint8

func Decode

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

func DecodeConfig

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

func Encode

func Encode(writer io.Writer, image image.Image) error

func LumaDiff

func LumaDiff(a, b Pixel) (int8, int8, int8)

func RGBDiff

func RGBDiff(a, b Pixel) (int8, int8, int8)

Types

type Chunk

type Chunk interface {
	encoding.BinaryMarshaler
	encoding.BinaryUnmarshaler
	Pixels(decoder *Decoder) []Pixel
}

type Decoder

type Decoder struct {
	LastPixels    [64]Pixel
	PreviousPixel Pixel
}

func (*Decoder) Decode

func (decoder *Decoder) Decode(reader io.Reader) (image.Image, error)

func (*Decoder) SetPreviousPixel

func (decoder *Decoder) SetPreviousPixel(previousPixel Pixel)

type DiffChunk

type DiffChunk struct {
	RedDiff   int8
	GreenDiff int8
	BlueDiff  int8
}

func (*DiffChunk) MarshalBinary

func (chunk *DiffChunk) MarshalBinary() ([]byte, error)

func (*DiffChunk) Pixels

func (chunk *DiffChunk) Pixels(decoder *Decoder) []Pixel

func (*DiffChunk) String

func (chunk *DiffChunk) String() string

func (*DiffChunk) UnmarshalBinary

func (chunk *DiffChunk) UnmarshalBinary(data []byte) error

type Encoder

type Encoder struct {
	Image         image.Image
	LastPixels    [64]Pixel
	PreviousPixel Pixel
	CurrentRun    uint8
}

func (*Encoder) Encode

func (encoder *Encoder) Encode(w io.Writer) error

func (*Encoder) HasPixelCached

func (encoder *Encoder) HasPixelCached(pixel Pixel) bool

func (*Encoder) IsLumaDiff

func (encoder *Encoder) IsLumaDiff(pixel Pixel) bool

func (*Encoder) IsMinorDiff

func (encoder *Encoder) IsMinorDiff(pixel Pixel) bool

func (*Encoder) SetPreviousPixel

func (encoder *Encoder) SetPreviousPixel(previousPixel Pixel)
type Header struct {
	Width      uint32
	Height     uint32
	Channels   uint8
	Colorspace uint8
}

func (*Header) MarshalBinary

func (header *Header) MarshalBinary() ([]byte, error)

func (*Header) UnmarshalBinary

func (header *Header) UnmarshalBinary(data []byte) error

type IndexChunk

type IndexChunk struct {
	Index uint8
}

func (*IndexChunk) MarshalBinary

func (chunk *IndexChunk) MarshalBinary() (data []byte, err error)

func (*IndexChunk) Pixels

func (chunk *IndexChunk) Pixels(decoder *Decoder) []Pixel

func (*IndexChunk) String

func (chunk *IndexChunk) String() string

func (*IndexChunk) UnmarshalBinary

func (chunk *IndexChunk) UnmarshalBinary(data []byte) error

type LumaChunk

type LumaChunk struct {
	GreenDiff int8
	RedDiff   int8
	BlueDiff  int8
}

func (*LumaChunk) MarshalBinary

func (chunk *LumaChunk) MarshalBinary() ([]byte, error)

func (*LumaChunk) Pixels

func (chunk *LumaChunk) Pixels(decoder *Decoder) []Pixel

func (*LumaChunk) String

func (chunk *LumaChunk) String() string

func (*LumaChunk) UnmarshalBinary

func (chunk *LumaChunk) UnmarshalBinary(data []byte) error

type Pixel

type Pixel [4]byte

func (Pixel) String

func (pixel Pixel) String() string

type RGBAChunk

type RGBAChunk struct {
	Pixel
}

func (*RGBAChunk) MarshalBinary

func (chunk *RGBAChunk) MarshalBinary() ([]byte, error)

func (*RGBAChunk) Pixels

func (chunk *RGBAChunk) Pixels(*Decoder) []Pixel

func (*RGBAChunk) String

func (chunk *RGBAChunk) String() string

func (*RGBAChunk) UnmarshalBinary

func (chunk *RGBAChunk) UnmarshalBinary(data []byte) error

type RGBChunk

type RGBChunk struct {
	Pixel
}

func (*RGBChunk) MarshalBinary

func (chunk *RGBChunk) MarshalBinary() ([]byte, error)

func (*RGBChunk) Pixels

func (chunk *RGBChunk) Pixels(decoder *Decoder) []Pixel

func (*RGBChunk) String

func (chunk *RGBChunk) String() string

func (*RGBChunk) UnmarshalBinary

func (chunk *RGBChunk) UnmarshalBinary(data []byte) error

type RunChunk

type RunChunk struct {
	Length uint8
}

func (*RunChunk) MarshalBinary

func (chunk *RunChunk) MarshalBinary() ([]byte, error)

func (*RunChunk) Pixels

func (chunk *RunChunk) Pixels(decoder *Decoder) []Pixel

func (*RunChunk) String

func (chunk *RunChunk) String() string

func (*RunChunk) UnmarshalBinary

func (chunk *RunChunk) UnmarshalBinary(data []byte) error

Jump to

Keyboard shortcuts

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