papyrus logo

image.h

Go to the documentation of this file.
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 file is part of the papyrus library.                             *
00008  *                                                                         *
00009  *   papyrus is free software; you can redistribute it and/or modify       *
00010  *   it under the terms of the GNU Lesser General Public License           *
00011  *   version 3.0 as published by the Free Software Foundation.             *
00012  *                                                                         *
00013  *   papyrus is distributed in the hope that it will be useful,            *
00014  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00015  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00016  *   GNU Lesser General Public License version 3.0 for more details.       *
00017  *                                                                         *
00018  *   You should have received a copy of the GNU Lesser General Public      *
00019  *   License along with the papyrus library. If not, see                   *
00020  *   <http://www.gnu.org/licenses/>.                                       *
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

Generated on Fri Apr 16 12:40:10 2010 for papyrus by doxygen 1.6.1