pcx

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package pcx provides support for reading and writing PCX image files. PCX is a raster image format originally developed by ZSoft Corporation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertToBMP

func ConvertToBMP(w io.Writer, r io.Reader) error

ConvertToBMP converts a PCX image to BMP format

func ConvertToGIF

func ConvertToGIF(w io.Writer, r io.Reader) error

ConvertToGIF converts a PCX image to GIF format

func ConvertToGIFWithPalette

func ConvertToGIFWithPalette(w io.Writer, r io.Reader, pal *gaf.Palette) error

ConvertToGIFWithPalette converts a PCX file to GIF using a custom palette

func ConvertToPNG

func ConvertToPNG(w io.Writer, r io.Reader) error

ConvertToPNG converts a PCX image to PNG format

Types

type Header struct {
	Manufacturer byte   // Always 0x0A
	Version      byte   // Version information
	Encoding     byte   // 1 = RLE encoding
	BitsPerPixel byte   // Bits per pixel per plane
	XMin         uint16 // Image dimensions
	YMin         uint16
	XMax         uint16
	YMax         uint16
	HorzDPI      uint16 // Horizontal DPI
	VertDPI      uint16 // Vertical DPI
	Palette      [48]byte
	Reserved     byte
	NumPlanes    byte   // Number of color planes
	BytesPerLine uint16 // Bytes per scan line per plane
	PaletteInfo  uint16 // How to interpret palette (1=color, 2=grayscale)
	HorzScreen   uint16 // Horizontal screen size
	VertScreen   uint16 // Vertical screen size
	Filler       [54]byte
}

Header represents the PCX file header

type Reader

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

Reader provides methods for reading PCX files

func LoadFromReader

func LoadFromReader(r io.Reader) (*Reader, error)

OpenReader opens a PCX file for reading

func (*Reader) BitsPerPixel

func (r *Reader) BitsPerPixel() int

BitsPerPixel returns the total bits per pixel

func (*Reader) Decode

func (r *Reader) Decode() (image.Image, error)

Decode decodes the PCX image and returns an image.Image

func (*Reader) EmbeddedPalette

func (r *Reader) EmbeddedPalette() *gaf.Palette

EmbeddedPalette returns the 256-color palette embedded at the end of the PCX file as a *gaf.Palette. Returns nil if the file does not carry an embedded palette (PCX header signals the 0x0C marker before the trailing 768 bytes).

TA: Kingdoms uses sidecar PCX files (often 1x1 px) purely as palette containers next to .gaf files, so this is the canonical way to fish the palette out without re-decoding the image data.

func (*Reader) HasEmbeddedPalette

func (r *Reader) HasEmbeddedPalette() bool

HasEmbeddedPalette returns true if the PCX file has an embedded 256-color palette

func (*Reader) Header

func (r *Reader) Header() *Header

Header returns the PCX file header

func (*Reader) Height

func (r *Reader) Height() int

Height returns the image height

func (*Reader) Width

func (r *Reader) Width() int

Width returns the image width

Jump to

Keyboard shortcuts

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