|
Rapicorn - Experimental UI Toolkit - Source Code 10.08.1
|
00001 /* Rapicorn - experimental UI toolkit 00002 * Copyright (C) 2008 Tim Janik 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Lesser General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 2.1 of the License, or (at your option) any later version. 00008 * 00009 * This library 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 GNU 00012 * Lesser General Public License for more details. 00013 * 00014 * A copy of the GNU Lesser General Public License should ship along 00015 * with this library; if not, see http://www.gnu.org/copyleft/. 00016 */ 00017 #ifndef __RAPICORN_PIXMAP_HH__ 00018 #define __RAPICORN_PIXMAP_HH__ 00019 00020 #include <rcore/utilities.hh> 00021 00022 namespace Rapicorn { 00023 00024 class Pixbuf { 00025 uint32 *m_pixels; 00026 protected: 00027 const int m_rowstride; 00028 const int m_width, m_height; 00029 virtual ~Pixbuf (); 00030 explicit Pixbuf (uint _width, uint _height, int alignment = -1); 00031 public: 00032 int width () const { return m_width; } 00033 int height () const { return m_height; } 00034 const uint32* row (uint y) const; /* endian dependant ARGB integers */ 00035 bool compare (const Pixbuf &source, 00036 uint sx, uint sy, int swidth, int sheight, 00037 uint tx, uint ty, 00038 double *averrp = NULL, double *maxerrp = NULL, 00039 double *nerrp = NULL, double *npixp = NULL) const; 00040 static bool try_alloc (uint width, uint height, int alignment = -1); 00041 static bool save_png (const String &filename, /* assigns errno */ 00042 const Pixbuf &pixbuf, 00043 const String &comment); 00044 }; 00045 00046 class Pixmap : public Pixbuf, public virtual BaseObject { 00047 String m_comment; 00048 protected: 00049 virtual ~Pixmap (); 00050 public: 00051 explicit Pixmap (uint _width, uint _height, int alignment = -1); 00052 String comment () const { return m_comment; } 00053 void comment (const String &_comment); 00054 uint32* row (uint y) { return const_cast<uint32*> (Pixbuf::row (y)); } 00055 uint32* data (int *stride); // stride in bytes 00056 using Pixbuf::row; 00057 bool save_png (const String &filename); /* assigns errno */ 00058 void copy (const Pixmap &source, 00059 uint sx, uint sy, int swidth, int sheight, 00060 uint tx, uint ty); 00061 static Pixmap* load_png (const String &filename, /* assigns errno */ 00062 bool tryrepair = false); 00063 static Pixmap* pixstream (const uint8 *pixstream); /* assigns errno */ 00064 static Pixmap* stock (const String &stock_name); 00065 static void add_stock (const String &stock_name, 00066 const uint8 *pixstream); 00067 }; 00068 00069 } // Rapicorn 00070 00071 #endif /* __RAPICORN_PIXMAP_HH__ */
1.7.4