Rapicorn - Experimental UI Toolkit - Source Code  13.07.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
pixmap.hh
Go to the documentation of this file.
00001  // Licensed GNU LGPL v3 or later: http://www.gnu.org/licenses/lgpl.html
00002 #ifndef __RAPICORN_PIXMAP_HH__
00003 #define __RAPICORN_PIXMAP_HH__
00004 
00005 #include <rcore/blobres.hh>
00006 
00007 namespace Rapicorn {
00008 
00016 template<class Pixbuf>
00017 class PixmapT {
00018   std::shared_ptr<Pixbuf> pixbuf_;
00019 public:
00020   explicit      PixmapT         ();                     
00021   explicit      PixmapT         (uint w, uint h);       
00022   explicit      PixmapT         (const Pixbuf &source); 
00023   explicit      PixmapT         (Blob &png_blob);       
00024   explicit      PixmapT         (const String &res_png); 
00025   PixmapT&      operator=       (const Pixbuf &source); 
00026   int           width           () const { return pixbuf_->width(); }  
00027   int           height          () const { return pixbuf_->height(); } 
00028   void          resize          (uint w, uint h);   
00029   bool          try_resize      (uint w, uint h);   
00030   const uint32* row             (uint y) const { return pixbuf_->row (y); } 
00031   uint32*       row             (uint y) { return pixbuf_->row (y); } 
00032   uint32&       pixel           (uint x, uint y) { return pixbuf_->row (y)[x]; }       
00033   uint32        pixel           (uint x, uint y) const { return pixbuf_->row (y)[x]; } 
00034   bool          load_png        (const String &filename, bool tryrepair = false); 
00035   bool          load_png        (size_t nbytes, const char *bytes, bool tryrepair = false); 
00036   bool          save_png        (const String &filename); 
00037   bool          load_pixstream  (const uint8 *pixstream); 
00038   void          set_attribute   (const String &name, const String &value); 
00039   String        get_attribute   (const String &name) const;                
00040   void          copy            (const Pixbuf &source, uint sx, uint sy,
00041                                  int swidth, int sheight, uint tx, uint ty); 
00042   bool          compare         (const Pixbuf &source, uint sx, uint sy, int swidth, int sheight,
00043                                  uint tx, uint ty, double *averrp = NULL, double *maxerrp = NULL, double *nerrp = NULL,
00044                                  double *npixp = NULL) const; 
00045   operator const Pixbuf& () const { return *pixbuf_; } 
00046 };
00047 
00048 // RAPICORN_PIXBUF_TYPE is defined in <clientapi.hh> and <serverapi.hh>
00049 typedef PixmapT<RAPICORN_PIXBUF_TYPE> Pixmap; 
00050 
00051 } // Rapicorn
00052 
00053 #endif /* __RAPICORN_PIXMAP_HH__ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines