palette

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package palette contains image and palette manipulation utilities.

Index

Constants

View Source
const Size = 256

Variables

This section is empty.

Functions

func OpenPalettedImage

func OpenPalettedImage(path string) (*image.Paletted, error)

func RemapLastColor

func RemapLastColor(img *image.Paletted, remapIndex uint8)
GoldSrc uses the last color of a palette to indicate what to use as the

* transparent color for masked transparency. If the palette is shorter than the * maximum the last color of the palette needs to be moved to the last spot and * all corresponding pixels also need to be updated to this new palette index.

Types

type Palette

type Palette [Size]RGB

func FromImage

func FromImage(img *image.Paletted) (Palette, uint8, bool, error)

Returns the final palette, the last index in the input palette, and true if this index must be remapped to 0xFF.

func (Palette) AsColorPalette

func (p Palette) AsColorPalette() color.Palette

type RGB

type RGB struct {
	R, G, B uint8
}

func RGBFromColor

func RGBFromColor(c color.Color) RGB

Jump to

Keyboard shortcuts

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