texture

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2025 License: BSD-3-Clause Imports: 8 Imported by: 1

Documentation

Overview

Package texture provides image types used by the rcp, e.g. textures and framebuffers.

Index

Constants

View Source
const (
	RGBA32 = Format(RGBA) | Format(BPP32)
	RGBA16 = Format(RGBA) | Format(BPP16)
	YUV16  = Format(YUV) | Format(BPP16)
	IA16   = Format(IA) | Format(BPP16)
	IA8    = Format(IA) | Format(BPP8)
	IA4    = Format(IA) | Format(BPP4)
	I8     = Format(I) | Format(BPP8)
	I4     = Format(I) | Format(BPP4)
	CI8    = Format(CI) | Format(BPP8)
	CI4    = Format(CI) | Format(BPP4)
)

Variables

View Source
var I4Model color.Model = color.ModelFunc(i4Model)
View Source
var RGBA16Model color.Model = color.ModelFunc(rgba16Model)

Functions

This section is empty.

Types

type ColorPalette

type ColorPalette = imageRGBA16

ColorPalette is a palette of RGBA16 colors.

func CopyColorPalette

func CopyColorPalette(src color.Palette) (*ColorPalette, error)

func NewColorPalette

func NewColorPalette(size int) (*ColorPalette, error)

func (*ColorPalette) Convert

func (p *ColorPalette) Convert(c color.Color) color.Color

Convert returns the palette color closest to c in Euclidean R,G,B space.

func (*ColorPalette) Index

func (p *ColorPalette) Index(c color.Color) int

Index returns the index of the palette color closest to c in Euclidean R,G,B,A space.

type Components

type Components uint64
const (
	RGBA Components = iota << 53
	YUV
	CI // Color Palette
	IA // Intensity with alpha
	I  // Intensity
)

type Depth

type Depth uint64
const (
	BPP4 Depth = iota << 51
	BPP8
	BPP16
	BPP32
)

type Format

type Format uint64

func (Format) Bits

func (c Format) Bits(pixels int) int

Bits returns the size in bits for a number of pixels.

func (Format) Bytes

func (c Format) Bytes(pixels int) int

Bytes returns the size in bytes for a number of pixels.

func (Format) Components

func (c Format) Components() Components

func (Format) Depth

func (c Format) Depth() Depth

func (Format) SetDepth

func (c Format) SetDepth(bpp Depth) Format

func (Format) TMEMWords

func (c Format) TMEMWords(pixels int) int

TMEMWords returns the size in TMEM words (8 byte) for a number of pixels.

type Texture

type Texture struct {
	draw.Image
	// contains filtered or unexported fields
}

func Load

func Load(r io.Reader) (tex *Texture, err error)

func NewAlpha

func NewAlpha(r image.Rectangle) *Texture

Stores pixels alpha with 8bit

func NewCI8

func NewCI8(r image.Rectangle, palette *ColorPalette) *Texture

Stores pixels color index in a RGBA16 palette

func NewFramebuffer added in v0.1.1

func NewFramebuffer(r image.Rectangle) *Texture

Stores pixels alpha-premultiplied in RGBA with 32bit (8:8:8:8)

func NewI4

func NewI4(r image.Rectangle) *Texture

Stores pixels intensity with 4bit

func NewI8

func NewI8(r image.Rectangle) *Texture

Stores pixels intensity with 8bit

func NewRGBA16

func NewRGBA16(r image.Rectangle) *Texture

Stores pixels in RGBA with 16bit (5:5:5:1)

func NewRGBA32

func NewRGBA32(r image.Rectangle) *Texture

Stores pixels in RGBA with 32bit (8:8:8:8)

func NewTextureFromImage

func NewTextureFromImage(img image.Image) (tex *Texture)

func (*Texture) Addr

func (p *Texture) Addr() cpu.Addr

Addr returns the base address of the images pixel data.

func (*Texture) Format

func (p *Texture) Format() Format

Format returns the pixel's color format.

func (*Texture) HasAlpha added in v0.1.1

func (p *Texture) HasAlpha() bool

func (*Texture) Invalidate

func (p *Texture) Invalidate()

func (*Texture) Palette

func (p *Texture) Palette() *Texture

Palette returns the color palette texture for formats CI4 and CI8.

func (*Texture) Pix added in v0.1.1

func (p *Texture) Pix() []byte

Addr returns a pointer to the images pixel data.

func (*Texture) SetOrigin

func (p *Texture) SetOrigin(origin image.Point)

SetOrigin moves the coordinate system of the texture to origin. Useful if subimages are used as viewports and should have their origin in (0, 0).

func (*Texture) Store

func (p *Texture) Store(w io.Writer) error

func (*Texture) Stride

func (p *Texture) Stride() int

Stride returns the stride (in pixels) between vertically adjacent pixels.

func (*Texture) SubImage

func (p *Texture) SubImage(r image.Rectangle) *Texture

func (*Texture) Writeback

func (p *Texture) Writeback()

Jump to

Keyboard shortcuts

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