PNG

Implements the Portable Network Graphics file format as a class.

Supports APNG extenstions.

public
class PNG : Image , MultiImage , CustomImageMetadata {}

Constructors

this
this(IImageData imgDat, IPalette pal)

Creates an empty PNG file in memory

this
this()
Undocumented in source.

Members

Classes

EmbeddedData
class EmbeddedData

Stores ancillary data embedded into PNG files. Handling these are not vital for opening PNG files, but available for various purposes. Please be aware that certain readers might have issues with nonstandard chunks

Enums

ChecksumPolicy
enum ChecksumPolicy

Used for static function load. Selects checksum checking policy.

ChunkInitializers
enum ChunkInitializers

Chunk initializer IDs.

ColorType
enum ColorType

Represents the possible types for PNG While bitmasking could be used, not every combination are valid

FilterType
enum FilterType

Defines standard PNG filter types.

Flags
enum Flags

Defines the flags in the flag field.

FrameBlendOperator
enum FrameBlendOperator

Frame blend operator.

FrameDisposalOperator
enum FrameDisposalOperator

Frame disposal operator.

Functions

addAncilliaryChunk
void addAncilliaryChunk(EmbeddedData.DataPosition pos, char[4] identifier, ubyte[] data)

Adds an ancillary chunk to the PNG file

frameTime
uint frameTime()
Undocumented in source. Be warned that the author may not have intended to support it.
getAuthor
string getAuthor()
Undocumented in source. Be warned that the author may not have intended to support it.
getBitdepth
ubyte getBitdepth()
Undocumented in source. Be warned that the author may not have intended to support it.
getComment
string getComment()
Undocumented in source. Be warned that the author may not have intended to support it.
getCopyright
string getCopyright()
Undocumented in source. Be warned that the author may not have intended to support it.
getCreationTimeStr
string getCreationTimeStr()
Undocumented in source. Be warned that the author may not have intended to support it.
getCurrentImage
uint getCurrentImage()
Undocumented in source. Be warned that the author may not have intended to support it.
getDescription
string getDescription()
Undocumented in source. Be warned that the author may not have intended to support it.
getHeader
Header getHeader()

Returns the header.

getID
string getID()
Undocumented in source. Be warned that the author may not have intended to support it.
getJobName
string getJobName()
Undocumented in source. Be warned that the author may not have intended to support it.
getMetadata
string getMetadata(string id)
Undocumented in source. Be warned that the author may not have intended to support it.
getPaletteBitdepth
ubyte getPaletteBitdepth()
Undocumented in source. Be warned that the author may not have intended to support it.
getPalettePixelFormat
uint getPalettePixelFormat()
Undocumented in source. Be warned that the author may not have intended to support it.
getPixelFormat
uint getPixelFormat()
Undocumented in source. Be warned that the author may not have intended to support it.
getSoftwareInfo
string getSoftwareInfo()
Undocumented in source. Be warned that the author may not have intended to support it.
getSoftwareVersion
string getSoftwareVersion()
Undocumented in source. Be warned that the author may not have intended to support it.
getSource
string getSource()
Undocumented in source. Be warned that the author may not have intended to support it.
height
uint height()
Undocumented in source. Be warned that the author may not have intended to support it.
isAnimation
bool isAnimation()
Undocumented in source. Be warned that the author may not have intended to support it.
isIndexed
bool isIndexed()
Undocumented in source. Be warned that the author may not have intended to support it.
nOfImages
uint nOfImages()
Undocumented in source. Be warned that the author may not have intended to support it.
save
void save(F file, int compLevel)

Saves the file to the disk. Currently interlaced mode is unsupported.

setAuthor
string setAuthor(string val)
Undocumented in source. Be warned that the author may not have intended to support it.
setComment
string setComment(string val)
Undocumented in source. Be warned that the author may not have intended to support it.
setCopyright
string setCopyright(string val)
Undocumented in source. Be warned that the author may not have intended to support it.
setCreationTime
string setCreationTime(string val)
Undocumented in source. Be warned that the author may not have intended to support it.
setCurrentImage
uint setCurrentImage(uint frame)
Undocumented in source. Be warned that the author may not have intended to support it.
setDescription
string setDescription(string val)
Undocumented in source. Be warned that the author may not have intended to support it.
setID
string setID(string val)
Undocumented in source. Be warned that the author may not have intended to support it.
setJobName
string setJobName(string val)
Undocumented in source. Be warned that the author may not have intended to support it.
setMetadata
string setMetadata(string id, string val)
Undocumented in source. Be warned that the author may not have intended to support it.
setSoftwareInfo
string setSoftwareInfo(string val)
Undocumented in source. Be warned that the author may not have intended to support it.
setSoftwareVersion
string setSoftwareVersion(string val)
Undocumented in source. Be warned that the author may not have intended to support it.
setSource
string setSource(string val)
Undocumented in source. Be warned that the author may not have intended to support it.
setStaticImage
void setStaticImage()

Sets the current image to the static if available

width
uint width()
Undocumented in source. Be warned that the author may not have intended to support it.

Static functions

filterScanlineAverage
ubyte[] filterScanlineAverage(ubyte[] target, ubyte[] prevScanline, int bytedepth)

Encodes a scanline using Average filter.

filterScanlinePaeth
ubyte[] filterScanlinePaeth(ubyte[] target, ubyte[] prevScanline, int bytedepth)

Encodes a scanline using Paeth filter.

filterScanlineSub
ubyte[] filterScanlineSub(ubyte[] target, int bytedepth)

Encodes a scanline using Sub filter.

filterScanlineUp
ubyte[] filterScanlineUp(ubyte[] target, ubyte[] prevScanline)

Encodes a scanline using Up filter.

load
PNG load(F file)

Loads a PNG file. Currently interlaced mode is unsupported.

paethFunc
ubyte paethFunc(ubyte a, ubyte b, ubyte c)

Paeth function for filtering and reconstruction.

reconstructScanlineAverage
ubyte[] reconstructScanlineAverage(ubyte[] target, ubyte[] prevScanline, int bytedepth)

Reconstructs a scanline from Average filtering

reconstructScanlinePaeth
ubyte[] reconstructScanlinePaeth(ubyte[] target, ubyte[] prevScanline, int bytedepth)

Reconstructs a scanline from Paeth filtering.

reconstructScanlineSub
ubyte[] reconstructScanlineSub(ubyte[] target, int bytedepth)

Reconstructs a scanline from Sub filtering.

reconstructScanlineUp
ubyte[] reconstructScanlineUp(ubyte[] target, ubyte[] prevScanline)

Reconstructs a scanline from Up filtering.

Static variables

PNG_CLOSER
enum ubyte[4] PNG_CLOSER;

Final checksum of IEND

PNG_SIGNATURE
enum ubyte[8] PNG_SIGNATURE;

Used for checking PNG files

Structs

AnimationControl
struct AnimationControl

Animation control chunk. If found in a PNG file, it means it has the APNG extensions.

Chunk
struct Chunk

PNG Chunk identifier

FrameControl
struct FrameControl

Frame control chunk.

Header
struct Header

Contains most data related to PNG files.

Text
struct Text

Contains textual metadata embedded into the file.

Variables

ancillaryChunks
EmbeddedData[] ancillaryChunks;

Stores ancilliary chunks that are not essential for image processing

baseImage
IImageData baseImage;

Base image if APNG chunks present.

bkgColor
RGB16_16_16BE bkgColor;

Background color

bkgIndex
int bkgIndex;

Background index

filterBytes
ubyte[] filterBytes;

Filterbytes for each scanline

flags
uint flags;

Stores property flags

frameFilterBytes
ubyte[][] frameFilterBytes;

Filterbytes for each frame (might be jagged)

frames
IImageData[] frames;

Extra frames for the APNG extension

header
Header header;
Undocumented in source.
pitch
size_t pitch;
Undocumented in source.
textData
Text[] textData;

Textual metadata

trns
RGB16_16_16BE trns;

Transparency

Inherited Members

From Image

_palette
IPalette _palette;

Contains palette data and information

_imageData
IImageData _imageData;

Contains image data and information.

mod
ubyte mod;

used for fast access of indexes DEPRECATED!

shift
ubyte shift;

used for fast access of indexes DEPRECATED!

width
uint width [@property getter]

Returns the width of the image in pixels.

height
uint height [@property getter]

Returns the height of the image in pixels.

isIndexed
bool isIndexed [@property getter]

Returns true if the image is indexed.

getBitdepth
ubyte getBitdepth [@property getter]

Returns the number of bits used per sample.

getPaletteBitdepth
ubyte getPaletteBitdepth [@property getter]

Returns the number of bits used per colormap entry.

getPixelFormat
uint getPixelFormat [@property getter]

Returns the pixelformat of the image. See enumerator PixelFormat for more info.

getPalettePixelFormat
uint getPalettePixelFormat [@property getter]

Returns the pixelformat of the palette. See enumerator PixelFormat for more info.

backgroundColorIndex
int backgroundColorIndex [@property getter]

Returns the background color index if there's any. Returns -1 if there's no background color, -2 if background color is not indexed.

backgroundColor
ARGB8888 backgroundColor [@property getter]

Returns the background color if there's any, or a default value otherwise.

getBitplanes
ubyte getBitplanes()

Returns the number of planes the image have. Default is one.

palette
IPalette palette()

Returns a palette range, which can be used to read the palette.

imageData
IImageData imageData()

Returns the image data.

readPixel
ARGB8888 readPixel(uint x, uint y)

Reads a single 32bit pixel. If the image is indexed, a color lookup will be done.

readPalette
ARGB8888 readPalette(size_t index)

Looks up the index on the palette, then returns the color value as a 32 bit value.

flipVertical
void flipVertical()

Flips the image on the vertical axis. Useful to set images to the correct top-left screen origin point.

flipHorizontal
void flipHorizontal()

Flips the image on the vertical axis. Useful to set images to the correct top-left screen origin point.

topOrigin
bool topOrigin()

Returns true if the image originates from the top

rightSideOrigin
bool rightSideOrigin()

Returns true if the image originates from the right

From MultiImage

getCurrentImage
uint getCurrentImage()

Returns which image is being set to be worked on.

setCurrentImage
uint setCurrentImage(uint frame)

Sets which image is being set to be worked on.

setStaticImage
void setStaticImage()

Sets the current image to the static if available

nOfImages
uint nOfImages()

Number of images in a given multi-image.

frameTime
uint frameTime()

Returns the frame duration in hmsec if animation for the given frame. Returns 0 if not an animation.

isAnimation
bool isAnimation()

Returns true if the multi-image is animated

From CustomImageMetadata

getMetadata
string getMetadata(string id)

Returns the metadata with the given id. Returns null if not found.

setMetadata
string setMetadata(string id, string val)

Sets the given metadata to val at the given id, then returns the new value.

Meta