00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef PAPYRUSIMAGE_H
00020 #define PAPYRUSIMAGE_H
00021
00022 #include <papyrus/drawable.h>
00023
00024 namespace Papyrus {
00025
00029 class Image : public Drawable {
00030 public:
00031 typedef PapyrusSmartPointer< Image > pointer;
00032
00033 Image();
00034
00035 Image( std::string filename );
00036
00037 Image( unsigned char* data, Cairo::Format format, int width, int height, int stride, bool convert_rgba=false );
00038
00039 Image( Cairo::Format format, int width, int height );
00040
00041 static Image::pointer create( );
00042
00043 static Image::pointer create( std::string filename );
00044
00045 static Image::pointer create( unsigned char* data, Cairo::Format format, int width, int height, int stride, bool convert_rgba=false );
00046
00047 static Image::pointer create( Cairo::Format format, int width, int height );
00048
00050 ~Image();
00051
00052 std::string filename() const;
00053
00054 void set_image( const std::string& filename );
00055
00056 void set_image( unsigned char* data, Cairo::Format format, int width, int height, int stride, bool convert_rgba=false );
00057
00058 void set_image( Cairo::Format format, int width, int height );
00059
00060 virtual void draw( Cairo::RefPtr<Cairo::Context> cairo );
00061
00062 double width();
00063
00064 double height();
00065
00066 void width_height( double& width, double& height );
00067
00068 PAPYRUS_CLASS_NAME("Image");
00069
00070 PAPYRUS_CLONE_METHOD( Image );
00071
00072 protected:
00073 std::string m_filename;
00074 double m_width, m_height;
00075 Cairo::RefPtr<Cairo::ImageSurface> m_image;
00076
00077 void on_image_changed();
00078 };
00079
00080 }
00081
00082 #endif