vee_image.h

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 
00003 /* COPYRIGHT
00004  *
00005  * This file is part of the Visual Effects Engine - VEE
00006  *
00007  * Read the "VEE-LICENSE" file for the license.
00008  *
00009  * Authors & Copyright:   
00010  *
00011  * Tommi Ilmonen, Tuukka Heikura, Marko Myllymaa and 
00012  * Janne Kontkanen 2001-2004
00013  *
00014  * Additional copyrights: Tekes 2003-2004
00015  *
00016  * firstname.lastname@hut.fi
00017  *
00018  */
00019 
00020 #ifndef VEE_IMAGE_H
00021 #define VEE_IMAGE_H
00022 
00023 #include <sys/types.h>
00024 
00025 class VEE_ImageIO;
00026 
00027 class VEE_Image
00028 {
00029 public:
00030 
00031   enum Channel {
00032     RedChannel,
00033     GreenChannel,
00034     BlueChannel,
00035     AlphaChannel
00036   };
00037 
00038   VEE_Image();
00039   ~VEE_Image();
00040 
00042   uint w() const { return m_width; }
00044   uint h() const { return m_height; }
00045 
00046   uint bytesPerPixel() const { return m_bytesPerPixel; }
00047 
00048   bool loadJpeg(const char *fileName);
00049   bool load(const char *fileName, int w = -1, int h = -1, int chans = -1);
00050   bool save(const char *fileName);
00051 
00053   void addAlpha();
00054 
00055   void alphaFromImageLuminance(const VEE_Image &img);
00056 
00057   double channelAverage(uint chan);
00058 
00060   void resize(uint w, uint h, uint bytesPerPixel);
00061 
00062   void resizeImage(uint w, uint h);
00063   void resizeImgToPowOfTwo();
00064 
00065   void mirrorXY();
00066 
00068   void randomValues();
00069   void perlinNoise(uint channel,
00070        double att, int octaves, double scale = 1.0,
00071        double z = 0.0, double amplitude = 1.0);
00072   void checkTexture(uint horizontalInterval,
00073         uint verticalInterval,
00074         const unsigned char * color1 = 0,
00075         const unsigned char * color2 = 0);
00076   void skotchTexture(uint stripeWidth,
00077          uint stripeInterval,
00078          const unsigned char * color1 = 0,
00079          const unsigned char * color2 = 0);
00080   void stripeTexture(uint stripeWidth,
00081          uint stripeInterval,
00082          const unsigned char * color1 = 0,
00083          const unsigned char * color2 = 0);       
00084   
00085   inline unsigned char *image() { return m_image; }
00086   inline const unsigned char *image() const { return m_image; }
00087 
00088   unsigned char *pixel(uint x, uint y);
00089   const unsigned char *pixelConst(uint x, uint y) const;
00090 
00091   unsigned char pixelLuminance(uint x, uint y) const;
00092 
00093   void copyPart(const VEE_Image &img, 
00094     uint startRow, uint endRow,
00095     uint startCol, uint endCol,
00096     uint offsetX = 0, uint offsetY = 0);
00097 
00099   void copyPartEnlarge(const VEE_Image &img, 
00100            uint ratio,
00101            uint startRow, uint endRow,
00102            uint startCol, uint endCol);
00103 
00104   void copyPartSmaller(const VEE_Image &img, 
00105            uint ratio,
00106            uint startRow, uint endRow,
00107            uint startCol, uint endCol);
00108 
00109   void evenGray(unsigned char v);
00110   void evenGray(uint channel, unsigned char v);
00111   void addRandom(uint channel, unsigned char amplitude);
00112   void channelCopy(uint targetChannel, uint sourceChannel);
00113   void channelSwap(uint c1, uint c2);
00114   void channelMultiply(uint target, uint source1, uint source2);
00115   void cosinePeak(uint channel, float power = 1.0, float radius = 0.5);
00116   void powerPeak(uint channel, float power = 1.0, float radius = 0.5);
00117   void boostRgb(int boost);
00118   void multiply(float mul);
00119   bool add(const VEE_Image &);
00120 
00122   void getSubpixel(unsigned char *target, double x, double y) const;
00124   void getMultipixel(unsigned char *target, uint x, uint y, uint size) const;
00125 
00126   VEE_Image & operator = (const VEE_Image &);
00127 
00128   static void test();
00129 
00130   static void addIO(VEE_ImageIO *);
00131 
00132 protected:
00133 
00134   unsigned char *m_image;
00136   uint m_rowSize;
00137   uint m_bytesPerPixel;
00138   uint m_width;
00139   uint m_height;
00140 
00141 private:
00142   VEE_Image(const VEE_Image &) {}
00143 
00144 };
00145 
00148 
00149 
00150 class VEE_ImageIO
00151 {
00152 public:
00153   VEE_ImageIO() {}
00154   virtual ~VEE_ImageIO() {}
00155 
00156   virtual bool read(VEE_Image *, const char *, int, int, int) = 0;
00157   virtual bool write(VEE_Image *, const char *) = 0;
00158   
00159 };
00160 
00161 #endif

Generated on Mon Mar 12 21:09:00 2007 for VEE - The Visual Effects Engine by  doxygen 1.4.6