Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

PNGGenerator Class Reference

Generates FilterBankEvents containing PNG compressed images. More...

#include <PNGGenerator.h>

Inheritance diagram for PNGGenerator:

Detailed Description

Generates FilterBankEvents containing PNG compressed images.

This class shares a lot of non-PNG specific code with JPEGGenerator, so you may want to replicate any changes made in that class as well.

Todo:
create a common super class with JPEGGenerator to hold common setup code

Definition at line 14 of file PNGGenerator.h.

List of all members.

Public Types

enum  src_mode_t { SRC_AUTO, SRC_GRAYSCALE, SRC_COLOR }
 

defines how to interpret the source images (see srcMode and curMode)

More...

Public Member Functions

 PNGGenerator (unsigned int mysid, FilterBankGenerator *fbg, EventBase::EventTypeID_t tid)
 constructor
 PNGGenerator (unsigned int mysid, PNGGenerator::src_mode_t sMode, FilterBankGenerator *fbg, EventBase::EventTypeID_t tid)
 constructor
virtual ~PNGGenerator ()
 destructor
virtual void setSourceMode (src_mode_t mode)
 set srcMode and curMode as well if mode==SRC_AUTO
virtual src_mode_t getSourceMode () const
 returns srcMode
virtual src_mode_t getCurrentSourceFormat () const
 returns curMode
virtual void doEvent ()
 should receive FilterBankEvents from a RawCameraGenerator (or a subclass thereof)
virtual unsigned int getBinSize () const
 if we don't already know bytesUsed, let's assume the size will be smaller than the original uncompressed. If we fail this assumption, probably better to fail anyway.
virtual unsigned int loadBuffer (const char buf[], unsigned int len, const char *filename=NULL)
virtual unsigned int saveBuffer (char buf[], unsigned int len) const
 you probably don't want to be calling this to access the PNG -- use getImage() instead (saveBuffer will prepend some header information before the actual image data)
virtual size_t getImageSize (unsigned int layer, unsigned int chan) const
 returns the number of bytes used for the image returned by getImage() - will return 0 if the image hasn't been calculated yet (so call it after getImage())

Static Public Member Functions

static std::string getClassDescription ()
 Gives a short description of what this class of behaviors does... you should override this (but don't have to).

Static Public Attributes

static const unsigned int PNG_HEADER_PAD = 500
 add a bit to the expected size in getBinSize just to leave a little extra room for small images

Protected Member Functions

virtual void setNumImages (unsigned int nLayers, unsigned int nChannels)
 resizes the filter bank information storage area, you should override this to do your setup and call it from your constructor
virtual unsigned char * createImageCache (unsigned int layer, unsigned int chan) const
 create new image data storage area for the cache - this called by getImage() only when the corresponding entry in images is NULL
virtual void calcImage (unsigned int layer, unsigned int chan)
 should calculate new image data, called by getImage() only when imageValids indicates the image being requested is dirty (and only after getImage() has already called createImageCache())
virtual void destruct ()
 deletes the arrays

Protected Attributes

src_mode_t srcMode
 how to interpret source channel of next filter bank event
src_mode_t curMode
 how to interpret getImage's current image
unsigned int ** bytesUsed
 number of bytes used per image to actually store data;

Private Member Functions

 PNGGenerator (const PNGGenerator &fbk)
 don't call
const PNGGeneratoroperator= (const PNGGenerator &fbk)
 don't call

Member Enumeration Documentation

defines how to interpret the source images (see srcMode and curMode)

Enumerator:
SRC_AUTO 

if src is not a InterleavedYUVGenerator, SRC_GREYSCALE, otherwise SRC_COLOR

SRC_GRAYSCALE 

indicates each channel of source should be compressed individually as grayscale images

SRC_COLOR 

indicates first channel should be in an interleaved layout which can be compressed into a "color" image

Definition at line 19 of file PNGGenerator.h.


Constructor & Destructor Documentation

PNGGenerator::PNGGenerator ( unsigned int  mysid,
FilterBankGenerator fbg,
EventBase::EventTypeID_t  tid 
)

constructor

Definition at line 13 of file PNGGenerator.cc.

PNGGenerator::PNGGenerator ( unsigned int  mysid,
PNGGenerator::src_mode_t  sMode,
FilterBankGenerator fbg,
EventBase::EventTypeID_t  tid 
)

constructor

Definition at line 28 of file PNGGenerator.cc.

PNGGenerator::~PNGGenerator (  )  [virtual]

destructor

Definition at line 45 of file PNGGenerator.cc.

PNGGenerator::PNGGenerator ( const PNGGenerator fbk  )  [private]

don't call


Member Function Documentation

void PNGGenerator::calcImage ( unsigned int  layer,
unsigned int  channel 
) [protected, virtual]

should calculate new image data, called by getImage() only when imageValids indicates the image being requested is dirty (and only after getImage() has already called createImageCache())

This is where you'll want to put your user-specific code for calculating the image data

Implements FilterBankGenerator.

Definition at line 183 of file PNGGenerator.cc.

unsigned char * PNGGenerator::createImageCache ( unsigned int  layer,
unsigned int  channel 
) const [protected, virtual]

create new image data storage area for the cache - this called by getImage() only when the corresponding entry in images is NULL

You should return the pointer you want stored in images to be returned by any calls to getFirstRow. Interpretation of the data it points to is dependant on the the generator which creates it

Implements FilterBankGenerator.

Definition at line 178 of file PNGGenerator.cc.

Referenced by loadBuffer().

void PNGGenerator::destruct (  )  [protected, virtual]

deletes the arrays

Reimplemented from FilterBankGenerator.

Definition at line 211 of file PNGGenerator.cc.

Referenced by ~PNGGenerator().

void PNGGenerator::doEvent (  )  [virtual]

should receive FilterBankEvents from a RawCameraGenerator (or a subclass thereof)

The const casts in this function are regretable but necessary since the corresponding OPEN-R functions require mutable arguments, even though they shouldn't be modifying the data

Reimplemented from FilterBankGenerator.

Definition at line 56 of file PNGGenerator.cc.

unsigned int PNGGenerator::getBinSize (  )  const [virtual]

if we don't already know bytesUsed, let's assume the size will be smaller than the original uncompressed. If we fail this assumption, probably better to fail anyway.

Reimplemented from FilterBankGenerator.

Definition at line 74 of file PNGGenerator.cc.

static std::string PNGGenerator::getClassDescription (  )  [static]

Gives a short description of what this class of behaviors does... you should override this (but don't have to).

If you do override this, also consider overriding getDescription() to return it

Reimplemented from BehaviorBase.

Definition at line 40 of file PNGGenerator.h.

virtual src_mode_t PNGGenerator::getCurrentSourceFormat (  )  const [virtual]

returns curMode

Definition at line 38 of file PNGGenerator.h.

Referenced by calcImage(), getBinSize(), loadBuffer(), and saveBuffer().

virtual size_t PNGGenerator::getImageSize ( unsigned int  layer,
unsigned int  chan 
) const [virtual]

returns the number of bytes used for the image returned by getImage() - will return 0 if the image hasn't been calculated yet (so call it after getImage())

Reimplemented from FilterBankGenerator.

Definition at line 54 of file PNGGenerator.h.

Referenced by CameraBehavior::doEvent().

virtual src_mode_t PNGGenerator::getSourceMode (  )  const [virtual]

returns srcMode

Definition at line 36 of file PNGGenerator.h.

Referenced by doEvent().

unsigned int PNGGenerator::loadBuffer ( const char  buf[],
unsigned int  len,
const char *  filename = NULL 
) [virtual]

The loadBuffer() functions of the included subclasses aren't tested, so don't assume they'll work without a little debugging...

Reimplemented from FilterBankGenerator.

Definition at line 94 of file PNGGenerator.cc.

const PNGGenerator& PNGGenerator::operator= ( const PNGGenerator fbk  )  [private]

don't call

unsigned int PNGGenerator::saveBuffer ( char  buf[],
unsigned int  len 
) const [virtual]

you probably don't want to be calling this to access the PNG -- use getImage() instead (saveBuffer will prepend some header information before the actual image data)

Reimplemented from FilterBankGenerator.

Definition at line 126 of file PNGGenerator.cc.

void PNGGenerator::setNumImages ( unsigned int  nLayers,
unsigned int  nChannels 
) [protected, virtual]

resizes the filter bank information storage area, you should override this to do your setup and call it from your constructor

In general, it isn't expected that FilterBankGenerator's should necessarily be dynamically resizeable (although it would be nice), which is why this isn't public. If yours is, just add some pubic accessor functions which call this. In general, the included subclasses should be able to handle being resized, but there's no reason to do so since the system won't be changing its available resolutions at run time.

The default implementation is a no-op if(numLayers==nLayers && numChannels==nChannels)

Reimplemented from FilterBankGenerator.

Definition at line 162 of file PNGGenerator.cc.

Referenced by PNGGenerator().

virtual void PNGGenerator::setSourceMode ( src_mode_t  mode  )  [virtual]

set srcMode and curMode as well if mode==SRC_AUTO

Definition at line 34 of file PNGGenerator.h.


Member Data Documentation

unsigned int** PNGGenerator::bytesUsed [protected]

number of bytes used per image to actually store data;

Definition at line 65 of file PNGGenerator.h.

Referenced by calcImage(), destruct(), getBinSize(), getImageSize(), loadBuffer(), saveBuffer(), and setNumImages().

how to interpret getImage's current image

Definition at line 63 of file PNGGenerator.h.

Referenced by doEvent(), getCurrentSourceFormat(), PNGGenerator(), and setSourceMode().

const unsigned int PNGGenerator::PNG_HEADER_PAD = 500 [static]

add a bit to the expected size in getBinSize just to leave a little extra room for small images

Definition at line 16 of file PNGGenerator.h.

Referenced by calcImage(), createImageCache(), and getBinSize().

how to interpret source channel of next filter bank event

Definition at line 62 of file PNGGenerator.h.

Referenced by getSourceMode(), PNGGenerator(), and setSourceMode().


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

Tekkotsu v5.1CVS
Generated Mon May 9 04:59:14 2016 by Doxygen 1.6.3