Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Namespace Members | Data Fields | Globals

Image.h

Go to the documentation of this file.
00001 /* Copyright (C) 2002 Dominic Letourneau (dominic.letourneau@usherbrooke.ca)
00002 
00003    This library is free software; you can redistribute it and/or
00004    modify it under the terms of the GNU Lesser General Public
00005    License as published by the Free Software Foundation; either
00006    version 2.1 of the License, or (at your option) any later version.
00007    
00008    This library is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011    Lesser General Public License for more details.
00012    
00013    You should have received a copy of the GNU Lesser General Public
00014    License along with this library; if not, write to the Free Software
00015    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00016 */
00017 #ifndef _IMAGE_H_
00018 #define _IMAGE_H_
00019 
00020 #include "Object.h"
00021 
00022 namespace RobotFlow {
00023 
00024 class Image : public FD::Object {
00025 
00026   friend class ImagePool;
00027 
00028  public:
00029 
00030   Image();
00031 
00032   Image(int width, int height, int pixelsize);
00033 
00034   Image(const Image & cpy);
00035 
00036   Image (const std::string &jpegfile);
00037 
00038   virtual ~Image();
00039   
00040   virtual void printOn(std::ostream &out = std::cout) const;
00041   
00042   virtual void readFrom(std::istream &in=std::cin);
00043   
00044   virtual void serialize(std::ostream &out) const;
00045   
00046   virtual void unserialize(std::istream &in);
00047 
00048   int get_size() {return m_size;}
00049 
00050   int get_width() {return m_width;}
00051 
00052   int get_height() {return m_height;}
00053 
00054   int get_pixelsize() {return m_size / (m_width * m_height);}
00055 
00056   unsigned char* get_data() {return m_data;}
00057 
00058   void put_data(unsigned char* data, int size);
00059 
00060   Image* sub_image(int x1, int y1, int x2, int y2);
00061   
00062   static Image* alloc(int width, int height, int pixelsize);
00063 
00064   virtual void destroy();
00065 
00066   int jpeg_compress(unsigned char*  buffer, int max_size, int quality);
00067 
00068   void jpeg_decompress(const unsigned char* buffer, int size);
00069 
00070   void load_jpeg(const std::string &jpegfile);
00071 
00072   void save_jpeg(const std::string &jpegfile, int quality);
00073 
00074   void rotate_180(Image &rotated_image);
00075   
00076   void merge(Image &upperLeft, Image &upperRight, Image &lowerLeft, Image &lowerRight);
00077 
00078  private:
00079 
00080   void update_size(int width, int height); 
00081 
00082   unsigned char* m_data;
00083   int m_width;
00084   int m_height;
00085   int m_size;
00086 
00087 };
00088 
00089 }//namespace RobotFlow
00090 
00091 #endif

Generated on Wed Oct 5 14:36:12 2005 for RobotFlow by  doxygen 1.4.4