Tekkotsu Homepage | Demos | Overview | Downloads | Dev. Resources | Reference | Credits |
PNGGenerator.hGo to the documentation of this file.00001 //-*-c++-*- 00002 #ifndef INCLUDED_PNGGenerator_h_ 00003 #define INCLUDED_PNGGenerator_h_ 00004 00005 #include "Vision/FilterBankGenerator.h" 00006 00007 //! Generates FilterBankEvents containing PNG compressed images 00008 /*! 00009 * This class shares a lot of non-PNG specific code with JPEGGenerator, 00010 * so you may want to replicate any changes made in that class as well. 00011 * 00012 * @todo create a common super class with JPEGGenerator to hold common setup code 00013 */ 00014 class PNGGenerator : public FilterBankGenerator { 00015 public: 00016 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 00017 00018 //! defines how to interpret the source images (see #srcMode and #curMode) 00019 enum src_mode_t { 00020 SRC_AUTO, //!< if src is not a InterleavedYUVGenerator, SRC_GREYSCALE, otherwise SRC_COLOR 00021 SRC_GRAYSCALE, //!< indicates each channel of source should be compressed individually as grayscale images 00022 SRC_COLOR //!< indicates first channel should be in an interleaved layout which can be compressed into a "color" image 00023 }; 00024 00025 //! constructor 00026 PNGGenerator(unsigned int mysid, FilterBankGenerator* fbg, EventBase::EventTypeID_t tid); 00027 //! constructor 00028 PNGGenerator(unsigned int mysid, PNGGenerator::src_mode_t sMode, FilterBankGenerator* fbg, EventBase::EventTypeID_t tid); 00029 00030 //! destructor 00031 virtual ~PNGGenerator(); 00032 00033 //! set #srcMode and #curMode as well if @a mode==SRC_AUTO 00034 virtual void setSourceMode(src_mode_t mode) { srcMode=mode; if(mode!=SRC_AUTO) curMode=mode;} 00035 //! returns #srcMode 00036 virtual src_mode_t getSourceMode() const { return srcMode; } 00037 //! returns #curMode 00038 virtual src_mode_t getCurrentSourceFormat() const { return curMode; } 00039 00040 static std::string getClassDescription() { return "Compresses its source FilterBankGenerator's data into PNG format"; } 00041 00042 //! should receive FilterBankEvents from a RawCameraGenerator (or a subclass thereof) 00043 virtual void processEvent(const EventBase& event); 00044 00045 //! 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. 00046 virtual unsigned int getBinSize() const; 00047 00048 virtual unsigned int loadBuffer(const char buf[], unsigned int len); 00049 00050 //! 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) 00051 virtual unsigned int saveBuffer(char buf[], unsigned int len) const; 00052 00053 //! 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 @e after getImage()) 00054 virtual unsigned int getImageSize(unsigned int layer, unsigned int chan) const { return bytesUsed[layer][chan]; } 00055 00056 protected: 00057 virtual void setNumImages(unsigned int nLayers, unsigned int nChannels); 00058 virtual unsigned char * createImageCache(unsigned int layer, unsigned int chan) const; 00059 virtual void calcImage(unsigned int layer, unsigned int chan); 00060 virtual void destruct(); 00061 00062 src_mode_t srcMode; //!< how to interpret source channel of next filter bank event 00063 src_mode_t curMode; //!< how to interpret getImage's current image 00064 00065 unsigned int ** bytesUsed; //!< number of bytes used per image to actually store data; 00066 00067 private: 00068 PNGGenerator(const PNGGenerator& fbk); //!< don't call 00069 const PNGGenerator& operator=(const PNGGenerator& fbk); //!< don't call 00070 }; 00071 00072 /*! @file 00073 * @brief Describes PNGGenerator, which generates FilterBankEvents containing PNG compressed images 00074 * @author Ethan Tira-Thompson (ejt) (Creator) 00075 * 00076 * $Author: ejt $ 00077 * $Name: tekkotsu-4_0 $ 00078 * $Revision: 1.4 $ 00079 * $State: Exp $ 00080 * $Date: 2007/04/09 22:22:05 $ 00081 */ 00082 00083 #endif |
Tekkotsu v4.0 |
Generated Thu Nov 22 00:54:55 2007 by Doxygen 1.5.4 |