• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

Bitmap.hpp

Go to the documentation of this file.
00001 
00002 
00003 
00004 #ifndef GOSU_BITMAP_HPP
00005 #define GOSU_BITMAP_HPP
00006 
00007 #include <Gosu/Color.hpp>
00008 #include <Gosu/Fwd.hpp>
00009 #include <Gosu/GraphicsBase.hpp>
00010 #include <boost/scoped_ptr.hpp>
00011 #include <string>
00012 #include <vector>
00013 
00014 namespace Gosu
00015 {
00020     class Bitmap
00021     {
00022         unsigned w, h;
00023         std::vector<Color> pixels;
00024 
00025     public:
00026         Bitmap();
00027 
00028         unsigned width() const { return w; }
00029         unsigned height() const { return h; }
00030 
00031         void swap(Bitmap& other);
00032 
00033         void resize(unsigned width, unsigned height, Color c = Color::NONE);
00034 
00035         void fill(Color c);
00036         void replace(Color oldColor, Color newColor);
00037 
00040         Color getPixel(unsigned x, unsigned y) const { return pixels[y * w + x]; }
00041 
00044         void setPixel(unsigned x, unsigned y, Color c) { pixels[y * w + x] = c; }
00045 
00049         void insert(const Bitmap& source, int x, int y);
00050 
00054         void insert(const Bitmap& source, int x, int y, unsigned srcX,
00055             unsigned srcY, unsigned srcWidth, unsigned srcHeight);
00056         
00059         const unsigned* data() const { return reinterpret_cast<const unsigned*>(&pixels[0]); }
00060         unsigned* data() { return reinterpret_cast<unsigned*>(&pixels[0]); }
00061     };
00062 
00064     Reader loadFromBMP(Bitmap& bmp, Reader reader);
00066     Writer saveToBMP(const Bitmap& bmp, Writer writer);
00068     Reader loadFromPNG(Bitmap& bmp, Reader reader);
00070     Writer saveToPNG(const Bitmap& bmp, Writer writer);
00071     
00075     void applyColorKey(Bitmap& bitmap, Color key);
00076     
00077     void applyBorderFlags(Bitmap& dest, const Bitmap& source,
00078         unsigned srcX, unsigned srcY, unsigned srcWidth, unsigned srcHeight,
00079         unsigned borderFlags);  
00080     
00082     Bitmap loadImageFile(const std::wstring& filename);
00084     Bitmap loadImageFile(Gosu::Reader input);
00085 }
00086 
00087 #endif

Documentation not clear enough? Please go to one of the places listed on http://www.libgosu.org/ and leave feedback. Thanks!