pvrz

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2018 License: BSD-2-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package pvrz provides functionality to deal with data of the PVR and PVRZ formats. It has been optimized for use in Enhanced Edition games based on the Infinity Engine.

Index

Constants

View Source
const (
	// Supported texture flags
	FLAGS_PREMULTIPLIED = 2 // Whether texture pixels are premultiplied by alpha

	// Supported compression type
	TYPE_BC1 = 7  // aka DXT1, full decoding and encoding support
	TYPE_BC2 = 9  // aka DXT3, full decoding and encoding support
	TYPE_BC3 = 11 // aka DXT5, full decoding and encoding support

	// Available color space constants
	SPACE_LRGB = 0 // linear RGB space (default)
	SPACE_SRGB = 1 // standard RGB space

	// Available channel types
	CHAN_UBN = 0 // Unsigned Byte Normalized (default)
	CHAN_SBN = 1 // Signed Byte Normalized
	CHAN_UB  = 2 // Unsigned Byte
	CHAN_SB  = 3 // Signed Byte

	// Available pixel encoding quality modes
	QUALITY_LOW     = 0 // Encode with lowest possible quality
	QUALITY_DEFAULT = 1 // Encode with a sensible quality/speed ratio
	QUALITY_HIGH    = 2 // Encoed with highest possiblle quality

)

Variables

View Source
var ErrIllegalArguments = errors.New("Illegal arguments specified")

Functions

This section is empty.

Types

type Pvr

type Pvr struct {
	// contains filtered or unexported fields
}

The main PVR structure.

func CreateNew

func CreateNew(width, height, pixelType int) *Pvr

CreateNew initializes a new Pvr object with an empty pixel buffer of specified dimension.

pixelType defines the pixel compression type applied when using the Save() function.

Note: It is strongly recommended to use a dimension that is compatible with the desired pixel compression.

func Load

func Load(r io.Reader) *Pvr

Load loads PVR or PVRZ data from the specified Reader.

func (*Pvr) ClearError

func (p *Pvr) ClearError()

ClearError clears the error state from the last Pvr operation. Must be called for subsequent operations to work correctly.

func (*Pvr) Error

func (p *Pvr) Error() error

Error returns the error state of the most recent operation on Pvr. Use ClearError() function to clear the current error state.

func (*Pvr) FillImageRect

func (p *Pvr) FillImageRect(r image.Rectangle, col color.Color)

FillImageRect fills the region "r" of the texture with the specified color.

func (*Pvr) GetChannelType

func (p *Pvr) GetChannelType() int

GetChannelType returns the size of individual pixel elements (r, g, b, a). Currently only byte-sized channel types are supported (see CHAN_xxx constants).

func (*Pvr) GetColorSpace

func (p *Pvr) GetColorSpace() int

GetColorSpace returns the color space used to represent pixel data. (see SPACE_xxx constants).

func (*Pvr) GetHeight

func (p *Pvr) GetHeight() int

GetHeight returns the height of the current pixel buffer in pixels.

func (*Pvr) GetImage

func (p *Pvr) GetImage() image.Image

GetImage returns a copy of the current texture graphics.

func (*Pvr) GetImageRect

func (p *Pvr) GetImageRect(r image.Rectangle) image.Image

GetImageRect returns the content of the texture in the specified region as a new Image object.

func (*Pvr) GetPixelType

func (p *Pvr) GetPixelType() int

GetPixelType returns the currently assigned pixel compression type applied when using the Save() function.

func (*Pvr) GetQuality

func (p *Pvr) GetQuality() int

GetQuality returns the quality mode applied to pixel compression (see QUALITY_xxx constants).

func (*Pvr) GetWeightByAlpha

func (p *Pvr) GetWeightByAlpha() bool

GetWeightByAlpha indicates whether pixel values are weighted by their alpha component when performing compression.

func (*Pvr) GetWidth

func (p *Pvr) GetWidth() int

GetWidth returns the width of the current pixel buffer in pixels.

func (*Pvr) IsPerceptiveMetric

func (p *Pvr) IsPerceptiveMetric() bool

IsPerceptiveMetric returns whether a perceptive metric is applied to pixel compression.

func (*Pvr) Save

func (p *Pvr) Save(w io.Writer, compress bool)

Save sends PVR data to the specified Writer.

Specify "compress" whether to write uncompressed PVR or compressed PVRZ data through the Writer. Note: Output texture dimension may be padded to meet pixel encoding requirements.

func (*Pvr) SetChannelType

func (p *Pvr) SetChannelType(channelType int)

SetChannelType defines the size of individual pixel elements (r, g, b, a). Currently only byte-sized channel types are supported (see CHAN_xxx constants).

func (*Pvr) SetColorSpace

func (p *Pvr) SetColorSpace(colorSpace int)

SetColorSpace defines the the color space used to represent pixel data. (see SPACE_xxx constants).

func (*Pvr) SetDimension

func (p *Pvr) SetDimension(width, height int, preserve bool)

SetDimension can be used to resize the current pixel buffer. Specify "preserve" to preserve as much of old content if possible.

func (*Pvr) SetImage

func (p *Pvr) SetImage(img image.Image)

SetImage replaces the current texture graphics with the specified image data.

Note: It is strongly recommended to use images with dimensions supported by the desired pixel encoding type.

func (*Pvr) SetImageRect

func (p *Pvr) SetImageRect(img image.Image, r image.Rectangle, dp image.Point)

SetImageRect draws the content of "img" limited by the region "r" to the texture starting at position "dp".

func (*Pvr) SetPerceptiveMetric

func (p *Pvr) SetPerceptiveMetric(set bool)

SetPerceptiveMetric defines whether a perceptive metric is applied to pixel compression.

func (*Pvr) SetPixelType

func (p *Pvr) SetPixelType(pixelType int)

SetPixelType sets the pixel compression type that is applied when using the Save() function.

func (*Pvr) SetQuality

func (p *Pvr) SetQuality(q int)

SetQuality defines the quality mode applied to pixel compression. Use one of the QUALITY_xxx constants.

func (*Pvr) SetWeightByAlpha

func (p *Pvr) SetWeightByAlpha(set bool)

SetWeightByAlpha defines whether pixel values are weighted by their alpha component when performing compression.

Jump to

Keyboard shortcuts

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