1 // Copyright (C) 2009 Ben Asselstine
3 // This program is free software; you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation; either version 3 of the License, or
6 // (at your option) any later version.
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU Library General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 #include "rectangle.h"
25 //! A pixmap and bitmask pair.
31 Glib::RefPtr<Gdk::Pixmap> get_pixmap() {return pixmap;};
32 Glib::RefPtr<Gdk::Bitmap> get_mask() {return mask;};
33 Glib::RefPtr<Gdk::GC> get_gc() {return gc;};
34 int get_width() {return width;};
35 int get_height() {return height;};
38 static PixMask* create(std::string file);
39 static PixMask* create(Glib::RefPtr<Gdk::Pixbuf> buf);
40 static PixMask* create(Glib::RefPtr<Gdk::Pixmap> pixmap,
41 Glib::RefPtr<Gdk::Bitmap> mask);
44 //! convert this pixmask to a pixbuf.
45 Glib::RefPtr<Gdk::Pixbuf> to_pixbuf();
47 //! draw a pixbuf onto this pixmask.
48 void draw_pixbuf(Glib::RefPtr<Gdk::Pixbuf> pixbuf, int src_x, int src_y, int dest_x, int dest_y, int width, int height);
50 //! scale a pixmask in place (alters pixmask)
51 static void scale(PixMask*& pixmask, int xsize, int ysize, Gdk::InterpType intper = Gdk::INTERP_NEAREST);
53 //! draw this pixmask onto a pixmap.
54 void blit(Glib::RefPtr<Gdk::Pixmap> pixmap, int dest_x, int dest_y);
55 void blit(Glib::RefPtr<Gdk::Pixmap> pixmap, Vector<int> pos = Vector<int>(0,0));
56 void blit_centered(Glib::RefPtr<Gdk::Pixmap> pixmap, Vector<int> pos);
57 // blit a tile's worth of imagery from this pixmask to a pixmap.
58 void blit(Vector<int> tile, int ts, Glib::RefPtr<Gdk::Pixmap> pixmap, Vector<int> dest = Vector<int>(0,0));
63 //! Default constructor.
64 PixMask(Glib::RefPtr<Gdk::Pixbuf> pixbuf);
66 //! Alternative constructor.
67 PixMask(Glib::RefPtr<Gdk::Pixmap> pixmap, Glib::RefPtr<Gdk::Bitmap> mask);
70 PixMask(const PixMask&);
72 //! Loading constructor.
74 * Load the pixmask from a file.
77 PixMask(std::string filename);
81 Glib::RefPtr<Gdk::Pixmap> pixmap;
82 Glib::RefPtr<Gdk::Bitmap> mask;
83 Glib::RefPtr<Gdk::GC> gc;
87 //! return a stretched copy of this pixmask.
88 PixMask* scale(int xsize, int ysize,
89 Gdk::InterpType interp = Gdk::INTERP_NEAREST);
91 void blit(Rectangle src, Glib::RefPtr<Gdk::Pixmap> pixmap, Vector<int> dest);