00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
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 }
00090
00091 #endif