apngasm
 All Classes Namespaces Functions Variables
Public Member Functions | List of all members
apngasm::APNGAsm Class Reference

The APNGAsm core class is all you need to assemble and disassemble Animated PNG. More...

#include <apngasm.h>

Public Member Functions

 APNGAsm (void)
 Construct an empty APNGAsm object.
 
 APNGAsm (const std::vector< APNGFrame > &frames)
 Construct APNGAsm object from an existing vector of apngasm frames. More...
 
 ~APNGAsm (void)
 APNGAsm destructor. !reset() is called here and will destroy the memory for all frames!
 
size_t addFrame (const std::string &filePath, unsigned delayNum=DEFAULT_FRAME_NUMERATOR, unsigned delayDen=DEFAULT_FRAME_DENOMINATOR)
 Adds a frame from a PNG file or frames from a APNG file to the frame vector. More...
 
size_t addFrame (const APNGFrame &frame)
 Adds an APNGFrame object to the frame vector. More...
 
APNGAsmoperator<< (const APNGFrame &frame)
 Adds an APNGFrame object to the frame vector. More...
 
bool assemble (const std::string &outputPath)
 Assembles and outputs an APNG file. More...
 
const std::vector< APNGFrame > & disassemble (const std::string &filePath)
 Disassembles an APNG file. More...
 
bool savePNGs (const std::string &outputDir) const
 Saves individual PNG files of the frames in the frame vector. More...
 
const std::vector< APNGFrame > & loadAnimationSpec (const std::string &filePath)
 Loads an animation spec from JSON or XML. Loaded frames are added to the end of the frame vector. For more details on animation specs see: https://github.com/Genshin/PhantomStandards. More...
 
bool saveJSON (const std::string &outputPath, const std::string &imageDir="") const
 Saves a JSON animation spec file. More...
 
bool saveXML (const std::string &outputPath, const std::string &imageDir="") const
 Saves an XML animation spec file. More...
 
void setAPNGAsmListener (listener::IAPNGAsmListener *listener=NULL)
 Sets a listener. More...
 
const std::vector< APNGFrame > & getFrames () const
 Returns the frame vector. More...
 
size_t frameCount ()
 Returns the number of frames. More...
 
size_t reset ()
 Destroy all frames in memory/dispose of the frame vector. Leaves the apngasm object in a clean state. More...
 
const char * version (void) const
 Returns the version of APNGAsm. More...
 

Detailed Description

The APNGAsm core class is all you need to assemble and disassemble Animated PNG.

Constructor & Destructor Documentation

apngasm::APNGAsm::APNGAsm ( const std::vector< APNGFrame > &  frames)

Construct APNGAsm object from an existing vector of apngasm frames.

Parameters
astd::vector of APNGFrame objects.

Member Function Documentation

size_t apngasm::APNGAsm::addFrame ( const std::string &  filePath,
unsigned  delayNum = DEFAULT_FRAME_NUMERATOR,
unsigned  delayDen = DEFAULT_FRAME_DENOMINATOR 
)

Adds a frame from a PNG file or frames from a APNG file to the frame vector.

Parameters
filePathThe relative or absolute path to an image file.
delayNumThe delay numerator for this frame (defaults to DEFAULT_FRAME_NUMERATOR).
delayDenThe delay denominator for this frame (defaults to DEFAULT_FRAME_DENMINATOR).
Returns
The [new] number of frames/the number of this frame on the frame vector.
size_t apngasm::APNGAsm::addFrame ( const APNGFrame frame)

Adds an APNGFrame object to the frame vector.

Parameters
framethe APNGFrame object to be added
Returns
The [new] number of frames/the number of this frame on the frame vector.
bool apngasm::APNGAsm::assemble ( const std::string &  outputPath)

Assembles and outputs an APNG file.

Parameters
outputPathThe output file path.
Returns
Returns true if assemble completed succesfully.
const std::vector< APNGFrame > & apngasm::APNGAsm::disassemble ( const std::string &  filePath)

Disassembles an APNG file.

Parameters
filePathThe file path to the PNG image to be disassembled.
Returns
A vector containing the frames of the disassembled PNG.
size_t apngasm::APNGAsm::frameCount ( )

Returns the number of frames.

Returns
Returns the number of frames.
const std::vector< APNGFrame > & apngasm::APNGAsm::getFrames ( ) const

Returns the frame vector.

Returns
Returns the frame vector.
const std::vector< APNGFrame > & apngasm::APNGAsm::loadAnimationSpec ( const std::string &  filePath)

Loads an animation spec from JSON or XML. Loaded frames are added to the end of the frame vector. For more details on animation specs see: https://github.com/Genshin/PhantomStandards.

Parameters
filePathThe path to the spec .xml or .json file.
Returns
A frame vector with the loaded frames.
APNGAsm & apngasm::APNGAsm::operator<< ( const APNGFrame frame)

Adds an APNGFrame object to the frame vector.

Parameters
frameAn APNGFrame object.
Returns
The [new] number of frames/the number of this frame on the frame vector.
size_t apngasm::APNGAsm::reset ( )

Destroy all frames in memory/dispose of the frame vector. Leaves the apngasm object in a clean state.

Returns
Retruns number of frames disposed of.
bool apngasm::APNGAsm::saveJSON ( const std::string &  outputPath,
const std::string &  imageDir = "" 
) const

Saves a JSON animation spec file.

Parameters
filePathPath to save the file to.
imageDirDirectory where frame files are to be saved if not the same path as the animation spec.
Returns
Returns true if save was successful.
bool apngasm::APNGAsm::savePNGs ( const std::string &  outputDir) const

Saves individual PNG files of the frames in the frame vector.

Parameters
fileDirThe directory where the PNG fils will be saved.
Returns
Returns true if all files were saved successfully.
bool apngasm::APNGAsm::saveXML ( const std::string &  outputPath,
const std::string &  imageDir = "" 
) const

Saves an XML animation spec file.

Parameters
filePathPath to save the file to.
imageDirDirectory where frame files are to be saved if not the same path as the animation spec.
Returns
Returns true if save was successful.
void apngasm::APNGAsm::setAPNGAsmListener ( listener::IAPNGAsmListener *  listener = NULL)

Sets a listener.

Parameters
listenerA pointer to the listener object. If the argument is NULL a default APNGAsmListener will be created and assigned.
const char * apngasm::APNGAsm::version ( void  ) const

Returns the version of APNGAsm.

Returns
Version string.