image.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef PAPYRUSIMAGE_H
00023 #define PAPYRUSIMAGE_H
00024
00025 #include <papyrus/drawable.h>
00026
00027 namespace Papyrus
00028 {
00029
00039 class Image : public Drawable
00040 {
00041 protected:
00042
00043 Image();
00044
00045 Image ( const Glib::ustring& id, const Glib::ustring& filename );
00046
00047 Image ( const Glib::ustring& id, unsigned char* data, Cairo::Format format, int width, int height, int stride, bool convert_rgba=false );
00048
00049 Image ( const Glib::ustring& id, Cairo::Format format, int width, int height );
00050
00057 Image ( const Glib::ustring& id, Cairo::RefPtr<Cairo::ImageSurface> img );
00058
00059 public:
00060 PAPYRUS_DRAWABLE(Image);
00061
00062 static pointer create( );
00063
00064 static pointer create ( const Glib::ustring& filename );
00065
00066 static pointer create ( unsigned char* data, Cairo::Format format, int width, int height, int stride, bool convert_rgba=false );
00067
00068 static pointer create ( Cairo::Format format, int width, int height );
00069
00079 static pointer create ( Cairo::RefPtr<Cairo::ImageSurface> img );
00080
00081 static pointer create ( const Glib::ustring& id, const Glib::ustring& filename );
00082
00083 static pointer create ( const Glib::ustring& id, unsigned char* data, Cairo::Format format, int width, int height, int stride, bool convert_rgba=false );
00084
00085 static pointer create ( const Glib::ustring& id, Cairo::Format format, int width, int height );
00086
00087 static pointer create ( const Glib::ustring& id, Cairo::RefPtr<Cairo::ImageSurface> img );
00088
00090 virtual ~Image();
00091
00092 Glib::ustring filename() const;
00093
00094 void set_image ( const Glib::ustring& filename );
00095
00096 void set_image ( unsigned char* data, Cairo::Format format, int width, int height, int stride, bool convert_rgba=false );
00097
00098 void set_image ( Cairo::Format format, int width, int height );
00099
00100 virtual bool inside ( double x, double y );
00101
00109 void set_image ( Cairo::RefPtr<Cairo::ImageSurface> img );
00110
00111 virtual void draw ( Context& cairo ) const;
00112
00113 double width();
00114
00115 double height();
00116
00117 void width_height ( double& width, double& height );
00118
00119 protected:
00120 Glib::ustring m_filename;
00121 double m_width, m_height;
00122 Cairo::RefPtr<Cairo::ImageSurface> m_image;
00123
00124 void on_image_changed();
00125
00126 virtual Region calculate_extents(const Matrix& m = Matrix::Identity, ExtentsPerformance ep = EXTENTS_QUICK) const;
00127
00128 };
00129
00130 }
00131
00132 #endif