Paul Heidmann Fractal Example  1.0
png::pngFactory Class Reference

This class provides an interface into libpng that is not completely insane (like libpng's native interface). The code in this class is fairly ugly. More...

#include <pngFactory.hpp>

Inheritance diagram for png::pngFactory:
Collaboration diagram for png::pngFactory:

Public Member Functions

 pngFactory ()=delete
 
 pngFactory (const std::uint16_t xResolution, const std::uint16_t yResolution, const std::string &pngOutFileName)
 This is the constructor that must be used to create instances of this class. More...
 
 ~pngFactory ()
 The class destructor. More...
 
void addPixel (const long double x, const long double y, const std::uint8_t red, const std::uint8_t green, const std::uint8_t blue)
 This method is called to add a pixel to the PNG image. More...
 
const std::uint16_t getXRes (void) const
 This method returns to the caller the horizontal resolution of the image. More...
 
const std::uint16_t getYRes (void) const
 This method returns to the caller the vertical resolution of the image. More...
 

Private Types

typedef std::tuple< long
double, long double,
std::uint8_t, std::uint8_t,
std::uint8_t > 
pixelType
 This type is used to define variables that hold single pixels. More...
 
typedef std::uint8_t * pngRowPtrType
 This type is used to access rows in the PNG image. More...
 

Private Member Functions

void allocatePngImageSpace (void)
 This method allocates space from the heap to hold the PNG image. More...
 
void deallocatePngImageSpace (void)
 This method deallocates the PNG image space. More...
 
void writePngFile (void)
 This method writes the PNG image out to disk. More...
 
void updateMinMax (const png::pngFactory::pixelType &p)
 This method is called to update the minimums and maximums, as tracked by this instance. More...
 
void findMinMax (void)
 This method is called to determine the minimums and maximums, as tracked by this instance. More...
 
void translatePixel (png::pngFactory::pixelType &p) const
 This method maps a single pixel from the user specified coordinate plane to pixel space. More...
 
void translateAllPixels (void)
 This method maps all pixels from the user specified coordinate plane to pixel space. More...
 
void renderAllPixels (void)
 This method renders all pixels. More...
 

Private Attributes

const std::string pFileName
 This attribute holds the name of the file into which the final PNG image is to placed. More...
 
const std::uint16_t xRes
 This attribute holds the X resolution of the PNG image. More...
 
const std::uint16_t yRes
 This attribute holds the Y resolution of the PNG image. More...
 
long double xMin
 This attribute holds the smallest x coordinate the caller has specified. More...
 
long double xMax
 This attribute holds the largest x coordinate the caller has specified. More...
 
long double yMin
 This attribute holds the smallest y coordinate the caller has specified. More...
 
long double yMax
 This attribute holds the largest y coordinate the caller has specified. More...
 
long double xTranslationFactor
 This attribute holds the scalar used to translate caller specified x coordinates into the image coordinate space. More...
 
long double yTranslationFactor
 This attribute holds the scalar used to translate caller specified y coordinates into the image coordinate space. More...
 
std::list
< png::pngFactory::pixelType
pxlLst
 This attribute holds all caller specified pixels. More...
 
png::pngFactory::pngRowPtrTypepngRowPointers
 This attribute holds a row pointer used to access the PNG image. More...
 
::png_structp pngStructPtr
 This attribute holds the libpng defined PNG structure used when generating the PNG image. More...
 
::png_infop pngInfoPtr
 This attribute holds the libpng defined PNG info structure used when generating the PNG image. More...
 

Detailed Description

This class provides an interface into libpng that is not completely insane (like libpng's native interface). The code in this class is fairly ugly.

Definition at line 37 of file pngFactory.hpp.

Member Typedef Documentation

typedef std::tuple< long double, long double, std::uint8_t, std::uint8_t, std::uint8_t> png::pngFactory::pixelType
private

This type is used to define variables that hold single pixels.

Definition at line 87 of file pngFactory.hpp.

typedef std::uint8_t* png::pngFactory::pngRowPtrType
private

This type is used to access rows in the PNG image.

Definition at line 90 of file pngFactory.hpp.

Constructor & Destructor Documentation

png::pngFactory::pngFactory ( )
delete
png::pngFactory::pngFactory ( const std::uint16_t  xResolution,
const std::uint16_t  yResolution,
const std::string &  pngOutFileName 
)

This is the constructor that must be used to create instances of this class.

Parameters
xResolutionThe horizontal resolution of the image.
yResolutionThe vertical resolution of the image.
pngOutFileNameThe filename of the final PNG image.

Definition at line 26 of file pngFactory.cpp.

References allocatePngImageSpace(), and pxlLst.

Here is the call graph for this function:

png::pngFactory::~pngFactory ( )

The class destructor.

Definition at line 45 of file pngFactory.cpp.

Member Function Documentation

void png::pngFactory::addPixel ( const long double  x,
const long double  y,
const std::uint8_t  red,
const std::uint8_t  green,
const std::uint8_t  blue 
)

This method is called to add a pixel to the PNG image.

Parameters
xThe X coordinate of the pixel.
yThe Y coordinate of the pixel.
redThe red component of the color of the pixel.
greenThe green component of the color of the pixel.
blueThe blue component of the color of the pixel.

Definition at line 54 of file pngFactory.cpp.

void png::pngFactory::allocatePngImageSpace ( void  )
private

This method allocates space from the heap to hold the PNG image.

Definition at line 80 of file pngFactory.cpp.

Referenced by pngFactory().

void png::pngFactory::deallocatePngImageSpace ( void  )
private

This method deallocates the PNG image space.

Definition at line 89 of file pngFactory.cpp.

void png::pngFactory::findMinMax ( void  )
private

This method is called to determine the minimums and maximums, as tracked by this instance.

Definition at line 154 of file pngFactory.cpp.

References updateMinMax().

Here is the call graph for this function:

const std::uint16_t png::pngFactory::getXRes ( void  ) const

This method returns to the caller the horizontal resolution of the image.

Returns
The X resolution of the image.

Definition at line 70 of file pngFactory.cpp.

const std::uint16_t png::pngFactory::getYRes ( void  ) const

This method returns to the caller the vertical resolution of the image.

Returns
The Y resolution of the image.

Definition at line 75 of file pngFactory.cpp.

void png::pngFactory::renderAllPixels ( void  )
private

This method renders all pixels.

Definition at line 187 of file pngFactory.cpp.

void png::pngFactory::translateAllPixels ( void  )
private

This method maps all pixels from the user specified coordinate plane to pixel space.

Definition at line 172 of file pngFactory.cpp.

References translatePixel().

Here is the call graph for this function:

void png::pngFactory::translatePixel ( png::pngFactory::pixelType p) const
private

This method maps a single pixel from the user specified coordinate plane to pixel space.

Parameters
pThe pixel to translate.

Definition at line 165 of file pngFactory.cpp.

Referenced by translateAllPixels().

void png::pngFactory::updateMinMax ( const png::pngFactory::pixelType p)
private

This method is called to update the minimums and maximums, as tracked by this instance.

Definition at line 139 of file pngFactory.cpp.

Referenced by findMinMax().

void png::pngFactory::writePngFile ( void  )
private

This method writes the PNG image out to disk.

Definition at line 96 of file pngFactory.cpp.

Member Data Documentation

const std::string png::pngFactory::pFileName
private

This attribute holds the name of the file into which the final PNG image is to placed.

Definition at line 94 of file pngFactory.hpp.

::png_infop png::pngFactory::pngInfoPtr
private

This attribute holds the libpng defined PNG info structure used when generating the PNG image.

Definition at line 139 of file pngFactory.hpp.

png::pngFactory::pngRowPtrType* png::pngFactory::pngRowPointers
private

This attribute holds a row pointer used to access the PNG image.

Definition at line 131 of file pngFactory.hpp.

::png_structp png::pngFactory::pngStructPtr
private

This attribute holds the libpng defined PNG structure used when generating the PNG image.

Definition at line 135 of file pngFactory.hpp.

std::list<png::pngFactory::pixelType> png::pngFactory::pxlLst
private

This attribute holds all caller specified pixels.

Definition at line 127 of file pngFactory.hpp.

Referenced by pngFactory().

long double png::pngFactory::xMax
private

This attribute holds the largest x coordinate the caller has specified.

Definition at line 108 of file pngFactory.hpp.

long double png::pngFactory::xMin
private

This attribute holds the smallest x coordinate the caller has specified.

Definition at line 104 of file pngFactory.hpp.

const std::uint16_t png::pngFactory::xRes
private

This attribute holds the X resolution of the PNG image.

Definition at line 97 of file pngFactory.hpp.

long double png::pngFactory::xTranslationFactor
private

This attribute holds the scalar used to translate caller specified x coordinates into the image coordinate space.

Definition at line 120 of file pngFactory.hpp.

long double png::pngFactory::yMax
private

This attribute holds the largest y coordinate the caller has specified.

Definition at line 116 of file pngFactory.hpp.

long double png::pngFactory::yMin
private

This attribute holds the smallest y coordinate the caller has specified.

Definition at line 112 of file pngFactory.hpp.

const std::uint16_t png::pngFactory::yRes
private

This attribute holds the Y resolution of the PNG image.

Definition at line 100 of file pngFactory.hpp.

long double png::pngFactory::yTranslationFactor
private

This attribute holds the scalar used to translate caller specified y coordinates into the image coordinate space.

Definition at line 124 of file pngFactory.hpp.


The documentation for this class was generated from the following files: