00001 #ifndef __OUR_IMAGE_TAG
00002 #define __OUR_IMAGE_TAG
00003
00004 #include<stdio.h>
00005 #include <string>
00006 #include "memory.h"
00007
00008 using namespace std;
00009
00010 #ifdef NO_MAGICK
00011
00019 int ReadJPEG(const char *filename,
00020 int & height, int & width,
00021 unsigned char * & image_buffer);
00022
00023 #else
00024 #include <Magick++.h>
00025 #endif
00026
00027
00028
00029 #ifndef NO_GUI
00030 #include <gtk/gtk.h>
00031
00037 void PixbufDestroy(guchar *pixels, gpointer data);
00038
00044 void new_window(GtkWidget * image, char * name);
00045 #endif
00046
00049 struct filter_exception{
00051 unsigned int line_number;
00053 string description;
00055 string file_name;
00056 };
00057
00058
00060 #define MAP_SIZE 256
00061
00062
00064 struct COLOR{
00065 unsigned char red;
00066 unsigned char green;
00067 unsigned char blue;
00068 };
00069
00074 bool is_imagefile(string FileName);
00075
00076
00078 class GrayImage{
00079 friend class ColorImage;
00080 public:
00081 GrayImage();
00082
00087 GrayImage(unsigned int height, unsigned int width);
00088
00092 GrayImage(string FileName);
00093
00094 #ifndef NO_MAGICK
00095
00098 GrayImage(Magick::Image & magick_image);
00099
00103 void fromMagickImage(Magick::Image & magick_image);
00104 #endif
00105
00109 GrayImage(const GrayImage & other);
00110
00112 ~GrayImage();
00113
00117 GrayImage & operator = (GrayImage & rhs);
00118
00123 unsigned char & elementAt(unsigned int x, unsigned int y);
00124
00125 #ifndef NO_GUI
00126
00129 GtkWidget * toGTK();
00130
00131 GdkPixbuf * toGDK();
00132 #endif
00133
00137 void readFile(string FileName);
00138
00143 void resize(int width, int height);
00144
00152 void cropCopy(const unsigned int x, const unsigned int y, GrayImage
00153 & to);
00154
00163 GrayImage * cropCopy(const unsigned int x, const unsigned int y,
00164 const unsigned int width, const unsigned int height);
00165
00169 GrayImage * copy();
00170
00175 void sample(GrayImage & to);
00176
00182 void equalize();
00183
00187 unsigned int getHeight(void);
00188
00192 unsigned int getWidth(void);
00193
00199 unsigned char* getData(void);
00200 protected:
00202 unsigned int height;
00204 unsigned int width;
00206 unsigned char * data;
00208 bool is_set;
00209 };
00210
00211
00212
00215 class ColorImage{
00216 friend class GrayImage;
00217 public:
00218
00220 ColorImage();
00221
00226 ColorImage(unsigned int height, unsigned int width);
00227
00231 ColorImage(string FileName);
00232
00233 #ifndef NO_MAGICK
00234
00237 ColorImage(Magick::Image & magick_image);
00238
00242 void fromMagickImage(Magick::Image & magick_image);
00243 #endif
00244
00248 ColorImage(const ColorImage & other);
00249
00251 ~ColorImage();
00252
00256 void readFile(string FileName);
00257
00258 #ifndef NO_GUI
00259
00262 GtkWidget * toGTK();
00263
00264 GdkPixbuf * toGDK();
00265 #endif
00266
00267
00271 GrayImage * toGrayImage();
00272
00280 void cropCopy(const unsigned int x, const unsigned int y, ColorImage & to);
00281
00292 ColorImage * cropCopy(const unsigned int x, const unsigned int y,
00293 const unsigned int width, const unsigned int height);
00294
00298 ColorImage * copy();
00299
00304 void sample(ColorImage & to);
00305
00311 void equalize();
00312
00318 COLOR & elementAt(unsigned int x, unsigned int y);
00319
00327 void dot(unsigned int x, unsigned int y, unsigned char red, unsigned char
00328 green, unsigned char blue);
00329
00339 void box(unsigned int x, unsigned int y, unsigned int width,
00340 unsigned int height, unsigned char red, unsigned char
00341 green, unsigned char blue);
00342
00346 unsigned int getHeight(void);
00347
00351 unsigned int getWidth(void);
00352
00358 COLOR * getData(void);
00359
00360 protected:
00362 int height;
00364 int width;
00366 COLOR * data;
00368 bool is_set;
00369 };
00370 #endif
00371
00372
00373
00374
00375