Documentation
¶
Overview ¶
Package utfextract provides parsing and image extraction for Microsoft Freelancer (2003) UTF binary files (.txm, .cmp, .3db, .mat, .dfm).
The UTF format is a tree of named nodes, each node holding either child nodes or raw binary data. Texture images (TGA or DDS) are stored inside a sub-tree called "Texture library".
Index ¶
- func CompositeOverWhite(img *image.NRGBA) *image.NRGBA
- func ExtractFromDir(inputDir, outputDir string, recursive, preservePaths bool, shapes *Shapes) (err error)
- func ExtractFromFile(inputPath, outputDir string, shapes *Shapes) error
- func TransformToJpeg(img *Image) (*bytes.Buffer, error)
- type ExtractedImage
- type Image
- type Node
- type Shape
- type ShapeOption
- type Shapes
- type ShapesConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractFromDir ¶
func ExtractFromDir(inputDir, outputDir string, recursive, preservePaths bool, shapes *Shapes) (err error)
ExtractFromDir walks inputDir for UTF files and extracts images into outputDir. When recursive is true it descends into sub-directories.
When preservePaths is true the sub-directory structure inside inputDir is mirrored under outputDir, so a file found at
inputDir/foo/bar/model.3db
produces images under
outputDir/foo/bar/model.3db/<imagefile>
rather than the flat
outputDir/model.3db/<imagefile>
Use preservePaths=true when validating output against a known-good reference tree extracted with the Perl tool.
func ExtractFromFile ¶
ExtractFromFile reads one UTF file and writes all found images into
outputDir/<basename>/<imagefile>
Returns the number of images written.
Types ¶
type ExtractedImage ¶
type ExtractedImage struct {
// Filename is the output path relative to the UTF file's output directory.
// May contain one sub-directory for multi-mip entries, e.g. "asterdust/MIP0.tga".
Filename string
Data []byte
}
ExtractedImage holds one image found inside a UTF file.
func ExtractImages ¶
func ExtractImages(raw []byte) ([]ExtractedImage, error)
ExtractImages parses a raw UTF file and returns all texture images found in its "Texture library" sub-tree.
type Node ¶
Node represents one entry in the UTF tree. Exactly one of Children or Data is non-nil.
type ShapeOption ¶
type ShapeOption func(s *Shapes)