00001 #ifndef IMAGE_WINDOW_H
00002 #define IMAGE_WINDOW_H
00003
00004 #include <GL/gl.h>
00005 #include <GL/glu.h>
00006 #include <glow.h>
00007
00008 #include "Image.h"
00009
00010
00011 GLOW_NAMESPACE_USING
00012
00013 enum MouseActionType { MOUSE_DOWN, MOUSE_UP };
00014
00015
00016 class ImageWindow : public GlowWindow
00025 {
00026 public:
00027
00028 bool newContent;
00029
00031 void (*mouse_press)(Glow::MouseButton button,int x, int y,Glow::Modifiers modifiers, MouseActionType action);
00032
00034 void (*mouse_move)(int x, int y);
00035
00037 void (*graphics_callback )(GlowComponent *parent) ;
00038
00039 protected:
00040
00041
00042
00043 unsigned int width;
00044 unsigned int height;
00045 unsigned int size;
00046 float scalefactor;
00047 bool size_changed;
00048
00049 Image::Type type;
00050 GLint *pixels;
00051 GLubyte *data;
00052 GLubyte *data_bk;
00053 GLubyte *data_grab;
00054
00055 volatile bool grab_display ;
00056 volatile bool grab_display_grey ;
00057 int *gd_ptr ;
00058
00059 public:
00060
00061
00062 ImageWindow(int width, int height, const char* title);
00063 ~ImageWindow();
00064
00065 void set_display_type(Image::Type t){ type = t; };
00066 void operator << (ImageRGB&);
00067 void operator << (ImageGrey&);
00068 void operator << (Image&);
00069 void operator >> (ImageRGB&);
00070 void operator >> (ImageGrey&);
00071 void set_zoom(float zoom);
00072 float get_zoom(){return scalefactor;}
00073
00074 protected:
00075
00076 virtual void OnEndPaint();
00077 virtual void OnMouseDown(Glow::MouseButton button,
00078 int x, int y,
00079 Glow::Modifiers modifiers);
00080 virtual void OnMouseUp(Glow::MouseButton button,
00081 int x, int y,
00082 Glow::Modifiers modifiers);
00083
00084 virtual void OnMouseMotion(int x, int y);
00085 void repackRGB();
00086 void repackGrey();
00087
00088 void grab_rgb() ;
00089 void grab_grey() ;
00090 };
00091
00092
00093 #endif // IMAGE_WINDOW_H