Archon::Utilities::FormatLibpng Struct Reference

An Image compatible frontend for libpng. More...

Inheritance diagram for Archon::Utilities::FormatLibpng:

Inheritance graph
[legend]
Collaboration diagram for Archon::Utilities::FormatLibpng:

Collaboration graph
[legend]
List of all members.

Public Member Functions

string getSpecifier () const
bool checkSignature (Ref< Stream::Reader > r) const
bool checkSuffix (string s) const
Image load (Ref< Stream::Reader > reader, Image::ProgressTracker *tracker, Logger *logger) const throw (Image::InvalidFormatException, IOException, UnexpectedException)
void save (Image image, Ref< Stream::Writer > writer, Image::ProgressTracker *tracker, Logger *logger) const throw (IOException, UnexpectedException)

Classes

struct  Context
struct  LoadContext
struct  LoadWrapper
struct  SaveContext
struct  SaveWrapper

Detailed Description

An Image compatible frontend for libpng.

See also:
http://www.libpng.org/pub/png
Rewritten and tested against libpng version 1.2.8.

Notes on using setjump/longjump in C++:

Great care must be taken when using setjump/longjump in C++ context. The main problem is that stack objects will not have their destructors called during a long jump stack unwinding process.

In this case we set up the long jump handler in a C++ function and then call a number of C (not C++) functions, and it is only these C functions that can potentially issue a long jump. This fact makes things a bit easier to control.

We should be safe as long as we stick to the following rules:

  1. Keep the setjump/longjump construction on the following canonical form:

       if(!setjmp(jmpbuf)) // try
       {
         // code that may potentially issue a long jump (throw)
       }
       else // catch
       {
         // code that handles the long jump (exception)
       }

     

  2. Keep the try-scope completely free of declarations of variables whos type have either an explicit or an implied destructor.

  3. For each C function call that may lead to a long jump make sure that the surrounding expression in the try-scope does not contain any temporary objects of a type that have either an explicit or an implied destructor.

  4. If any of the C function calls that may lead to a long jump calls a C++ function (eg. as a call back function) then make sure that the called C++ function does not issue a long jump or lead to one being issued in a place where stack variables with destructors are "live".

  5. Never long jump out of a C++ try block or catch block.

Definition at line 104 of file image_libpng.C.


Member Function Documentation

Image Archon::Utilities::FormatLibpng::load Ref< Stream::Reader reader,
Image::ProgressTracker tracker,
Logger logger
const throw (Image::InvalidFormatException, IOException, UnexpectedException) [inline, virtual]
 

Todo:
Still some confusion between bytes and chars.

Todo:
Read and somtimes transcode comments from image file.

Todo:
Read the comment.

Implements Archon::Utilities::Image::Format.

Definition at line 130 of file image_libpng.C.

References Archon::Utilities::Array< T >::get(), Archon::Utilities::Image::Format::getPixelBufferNoLeak(), Archon::Utilities::logger, Archon::Utilities::reader, and Archon::Utilities::Array< T >::reset().

void Archon::Utilities::FormatLibpng::save Image  image,
Ref< Stream::Writer writer,
Image::ProgressTracker tracker,
Logger logger
const throw (IOException, UnexpectedException) [inline, virtual]
 

Todo:
We need to verify that the combination of channels and bit-depth is acceptable for PNG.

Todo:
Verify the correctness of comment compression.

Implements Archon::Utilities::Image::Format.

Definition at line 244 of file image_libpng.C.

References Archon::Utilities::Image::components_l, Archon::Utilities::Image::components_la, Archon::Utilities::Image::components_rgb, Archon::Utilities::Image::components_rgba, Archon::Utilities::Array< T >::get(), Archon::Utilities::Image::Format::getPixelBufferNoLeak(), Archon::Utilities::CharEnc::ISO_8859_1, Archon::Utilities::logger, Archon::Utilities::Array< T >::reset(), Archon::Math::BasicVector< T, N >::size, Archon::Utilities::Text::toString(), Archon::Utilities::CharEnc::transcode(), Archon::Utilities::CharEnc::UTF_8, and Archon::Utilities::writer.


The documentation for this struct was generated from the following file:
Generated on Sun Jul 30 22:57:28 2006 for Archon by  doxygen 1.4.4