00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef PAPYRUSIMAGE_H
00022 #define PAPYRUSIMAGE_H
00023
00024 #include <papyrus/drawable.h>
00025
00026 namespace Papyrus
00027 {
00028
00036 class Image : public Drawable
00037 {
00038 public:
00039 typedef PapyrusSmartPointer< Image > pointer;
00040
00041 Image();
00042
00043 Image ( std::string filename );
00044
00045 Image ( unsigned char* data, Cairo::Format format, int width, int height, int stride, bool convert_rgba=false );
00046
00047 Image ( Cairo::Format format, int width, int height );
00048
00055 Image ( Cairo::RefPtr<Cairo::ImageSurface> img );
00056
00057 static Image::pointer create( );
00058
00059 static Image::pointer create ( std::string filename );
00060
00061 static Image::pointer create ( unsigned char* data, Cairo::Format format, int width, int height, int stride, bool convert_rgba=false );
00062
00063 static Image::pointer create ( Cairo::Format format, int width, int height );
00064
00074 static Image::pointer create ( Cairo::RefPtr<Cairo::ImageSurface> img );
00075
00077 ~Image();
00078
00079 std::string filename() const;
00080
00081 void set_image ( const std::string& filename );
00082
00083 void set_image ( unsigned char* data, Cairo::Format format, int width, int height, int stride, bool convert_rgba=false );
00084
00085 void set_image ( Cairo::Format format, int width, int height );
00086
00094 void set_image ( Cairo::RefPtr<Cairo::ImageSurface> img );
00095
00096 virtual void draw ( Cairo::RefPtr<Cairo::Context> cairo );
00097
00098 double width();
00099
00100 double height();
00101
00102 void width_height ( double& width, double& height );
00103
00104 PAPYRUS_CLASS_NAME ( "Image" );
00105
00106 PAPYRUS_CLONE_METHOD ( Image );
00107
00108 protected:
00109 std::string m_filename;
00110 double m_width, m_height;
00111 Cairo::RefPtr<Cairo::ImageSurface> m_image;
00112
00113 void on_image_changed();
00114 };
00115
00116 }
00117
00118 #endif