raster

package
v0.1.19 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDec    = fmt.Errorf("improperly initialized Decoder")
	ErrFormat = fmt.Errorf("unsupported image color model")
)

Functions

This section is empty.

Types

type DecodeConfigFunc

type DecodeConfigFunc func(io.Reader) (image.Config, error)

A DecodeConfigFunc reads from a source io.Reader and returns an image.Config and an error.

type DecodeFunc

type DecodeFunc func(io.Reader) (image.Image, error)

A DecodeFunc reads an image fom the source io.Reader and returns an image.Image and an error. Each of the standard library's image package subdirectories contain functions that can be used here, although alternative implementations are fine too.

type Decoder

type Decoder struct {
	DecodeFunc
	DecodeConfigFunc
}

A Decoder is a struct that can read gdf.XImages from source bytes. Most image codecs designed to be used with the standard library's image.RegisterFormat() function export functions that are useable as DecodeFunc and DecodeConfigFuncs. A Decoder can be reused on multiple images of the same format, although it is not concurrency safe. NOTE: For JPEG images, the gdf/jpeg package is more efficient.

func NewDecoder

func NewDecoder(df DecodeFunc, dcf DecodeConfigFunc) Decoder

func (Decoder) Decode

func (d Decoder) Decode(b []byte) (gdf.XImage, error)

Decode interprets b as data representing a raster image. It decodes the image and returns a gdf.XImage and an error. This function may not be ideal for all images. In particular, grayscale images with alpha channels are converted to their NRGBA equivalents, which may have the effect of significantly increasing the image's encoding size. Applications sensitive to performance may benefit from processing the image data separately and then generating the image's XImage representation by way of the gdf.LoadXImage function.

func (Decoder) DecodeFile

func (d Decoder) DecodeFile(path string) (gdf.XImage, error)

DecodeFile reads the contents of the file at the provided path and then calls Decode.

Jump to

Keyboard shortcuts

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