image.h

00001 /***************************************************************************
00002  *   Copyright (C) 2004 by Rick L. Vinyard, Jr.                            *
00003  *   rvinyard@cs.nmsu.edu                                                  *
00004  *                                                                         *
00005  *   Copyright (C) 2007 Peter Miller                                       *
00006  *                                                                         *
00007  *   This program is free software; you can redistribute it and/or modify  *
00008  *   it under the terms of the GNU Lesser General Public License as        *
00009  *   published by the Free Software Foundation version 2.1.                *
00010  *                                                                         *
00011  *   This program is distributed in the hope that it will be useful,       *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU General Public License for more details.                          *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Lesser General Public      *
00017  *   License along with this library; if not, write to the                 *
00018  *   Free Software Foundation, Inc.,                                       *
00019  *   51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA              *
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

Generated on Sun Mar 11 10:01:28 2007 by  doxygen 1.5.1