image.h

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

Generated on Sun Jan 7 22:53:57 2007 by  doxygen 1.5.1