Open Source Cross-Platform Game Programming

ImageEncoder

Library for converting ImageResource objects into various file format encodings.

class IconEncoder[link]

Encodes an ImageResource or a series of ImageResources into a list of bytes using the ICO format.

new IconEncoder()[link]

Creates a new Icon encoder. By default the icon encoder contains no images. As it supports multiple images at different resolutions, each must be added using addImage.

function addImage(imageResource)[link]

Adds an image to the icon file. The image will be padded and/or resized to fit the most appropriate resolution for .ico formats. Icon files support the following sizes: 16x16, 32x32, 64x64, 128x128, and 256x256. When an image is added that does not adhere to one of those sizes, it is converted to the largest size that it can fit into by adding invisible padding (it will be centered). If it is larger than 256x256, it will centered and cropped. Only one image is supported per size bucket. Images added that apply to an identical size buckets that a previous image was added to will be overwritten in the final output.

Arguments

NameTypeDescription
imageResource ImageResources.ImageResource

Image resource to add to the icon's images.

function encode()[link]

Emits the ICO file as a byte array. Throws a Core.InvalidState exception if the IconEncoder instance contains no images.

Return Value

TypeDescription
List of integers

List of bytes representing an icon file

class JpegEncoder[link]

Encodes an ImageResource into a list of bytes using the JPEG format.

new JpegEncoder(image)[link]

Creates a new PNG encoder

Arguments

NameTypeDescription
image ImageResources.ImageResource

Image resource to encode.

function encode()[link]

Emits the JPEG file as a byte array.

Return Value

TypeDescription
List of integers

List of bytes representing a JPEG file

class PngEncoder[link]

Encodes an ImageResource into a list of bytes using the PNG format.

new PngEncoder(image)[link]

Creates a new PNG encoder

Arguments

NameTypeDescription
image ImageResources.ImageResource

Image resource to encode.

function encode()[link]

Emits the PNG file as a byte array.

Return Value

TypeDescription
List of integers

List of bytes representing a PNG file