Documentation ¶
Overview ¶
Code generated by go generate; DO NOT EDIT. This file was generated automatically based on resource_files.csv
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUnsupportedTABOffset is thrown if the offset is not 2 or 4 ErrUnsupportedTABOffset = errors.New("unsupported offset size for TAB file") // ErrNotEnoughSprites is thrown if no (or not enough) images are found in ImageCollection. ErrNotEnoughSprites = errors.New("could not load sprites from file") // ErrNotEnoughTabs is thrown if not enough offsets are found to load PCK file. ErrNotEnoughTabs = errors.New("could not load offsets from tab file") )
var ( // ErrImageNotFound is thrown if path is not found in meta data map ErrImageNotFound = errors.New("image not found in meta data") // ErrNotImplemented is thrown if image type is not supported ErrNotImplemented = errors.New("not implemented yet") // ErrPaletteNotFound is thrown if specified colour pallete is not found ErrPaletteNotFound = errors.New("color pallete not found") )
var Images = map[string]ImageEntry{}/* 195 elements not displayed */
Functions ¶
Types ¶
type ImageCollection ¶
type ImageCollection struct { Sprites []*ImageResource SpriteWidth int }
ImageCollection is a list of ImageResources. These will typically be turned into a gallery or an animated image.
func LoadImageCollectionFromPCK ¶
func LoadImageCollectionFromPCK(path string, width int, offsets []int) (*ImageCollection, error)
LoadImageCollectionFromPCK loads a collection of images from a PCK file.
func (*ImageCollection) Gallery ¶
func (c *ImageCollection) Gallery(numberPerRow int, rowHeight int, palette *Palette) (image.Image, error)
Gallery creates a collection of all images on a grid with numberPerRow images in each row. The final size will depend on the number of Sprites in the collection (making up the grid), the size of the single SpriteWidth and the rowHeight.
type ImageEntry ¶
type ImageEntry struct { Format ImageFormat PaletteNr int Width int Height int TabFile string TabOffset int }
ImageEntry is a resource file for images in formats
type ImageFormat ¶ added in v0.1.3
type ImageFormat int
const ( ImageFormatUnknown ImageFormat = iota ImageFormatSPK ImageFormatPCK ImageFormatSCR )
type ImageResource ¶
type ImageResource struct {
// contains filtered or unexported fields
}
ImageResource is a list of pixels (colors) that will create an image of width.
func LoadPCK ¶
func LoadPCK(path string, width int, offset int) (*ImageResource, error)
LoadPCK loads PCK image from path.
func LoadSCR ¶
func LoadSCR(path string, width int) (*ImageResource, error)
LoadSCR loads an SCR image from path.
These ones are easy, every byte is an uncompressed index into the game's palette. Typically SCR files are used for 320x200 background images (and often stored in greyscale so they can be re-colored on the fly). DAT files that contain images use the same format, though the line width tends to vary depending on the specific use to which they are to be put.
func LoadSPK ¶
func LoadSPK(path string) (*ImageResource, error)
LoadSPK loads SPK image from path.
Another 320 pixels wide x 200 pixels high image format but using compression, primarily used by UFO for background images (eg inventory screens).
func (*ImageResource) Height ¶
func (i *ImageResource) Height() int
Height calculates the image's height in pixels.
func (*ImageResource) Image ¶
func (i *ImageResource) Image(palette *Palette) image.Image
Image will create an Image object with colors from palette.
func (*ImageResource) Paletted ¶
func (i *ImageResource) Paletted(palette *Palette) *image.Paletted
Paletted returns an image with a limited palette (used for GIFs).
func (*ImageResource) Width ¶
func (i *ImageResource) Width() int
Width returns the image's width in pixels.
type Palette ¶
type Palette struct { Colors [256]color.Color `struct:"[768]byte"` Buffer []byte `struct:"[6]byte"` }
Palette stores colours used for game images.
Back in the days of low video memory, storing each pixel as a multi-byte color value (such as in today's "High Color" and "True Color" modes common under MS Windows) was not practical. Instead, a common method for was to create a palette of 256 different colors (usually of 3 bytes each), and then use single byte values to index into that. The ability of a video card to use such a palette was known as "VGA compatibility".
This dramatically decreased the memory requirements of a given image, though it lowered the amount of colors that could be used in any single moment.
func LoadPalettes ¶
LoadPalettes loads Palettes from path. (see https://www.ufopaedia.org/index.php/PALETTES.DAT)
type ResourceLoader ¶
type ResourceLoader struct {
// contains filtered or unexported fields
}
ResourceLoader will load resources from game directory.
func NewResourceLoader ¶
func NewResourceLoader(root string) (*ResourceLoader, error)
NewResourceLoader will return a new instance of ResourceLoader.
func (*ResourceLoader) LoadImage ¶
func (rs *ResourceLoader) LoadImage(pth string) (image.Image, error)
LoadImage loads an image from pth with the palette as defined in resource list meta data. If pth is not found in meta data, an error is returned.
func (*ResourceLoader) LoadImageWithPalette ¶
LoadImageWithPalette loads an image with a specific colour palette.