diff options
Diffstat (limited to 'src/libjin/graphics/bitmap.h')
-rw-r--r-- | src/libjin/graphics/bitmap.h | 288 |
1 files changed, 144 insertions, 144 deletions
diff --git a/src/libjin/graphics/bitmap.h b/src/libjin/graphics/bitmap.h index 17dca40..c42fc23 100644 --- a/src/libjin/graphics/bitmap.h +++ b/src/libjin/graphics/bitmap.h @@ -12,150 +12,150 @@ namespace JinEngine { - namespace Graphics - { - - /// - /// A RGBA32 bitmap. - /// - /// A bitmap keeps pixels and can't draw directly onto screen. To render bitmap, a texture is required. A - /// texture is a renderable hard ware side structure which could be handled with GPU. For instance, opengl - /// create texture and store it in GPU memory for rendering them onto hdc. - /// - class Bitmap : public Object - { - public: - /// - /// Constructor of bitmap. - /// - Bitmap(); - - /// - /// Constructor of bitmap. - /// - /// @param width Width of bitmap. - /// @param height Height of bitmap. - /// - Bitmap(unsigned w, unsigned h); - - Bitmap(const char* path); - - Bitmap(const void* pixels, unsigned w, unsigned h); - - Bitmap(const void* imgData, size_t size); - - Bitmap(int w, int h, Color color); - - Bitmap(int w, int h, std::function<Color(int, int, int, int)> drawer); - - Bitmap(const Bitmap* bitmap); - - /// - /// Destructor of bitmap - /// - virtual ~Bitmap(); - - /// - /// Create bitmap with another one. - /// - /// @param bitmap Bitmap be cloned. - /// @return Return bitmap pointer if created, otherwise return null. - /// - Bitmap* clone(); - - /// - /// Directly bind pixels with given pixels data - /// - /// @param pixels Pixels to be binded. - /// @param width Width of bitmap - /// @param height Height of bitmap - /// - void bind(Color* pixels, int width, int height); - - /// - /// Reset pixel data with given pixels data. - /// - /// @param pixels Pixels to be set. - /// @param width Width of bitmap - /// @param height Height of bitmap - /// - void resetPixels(const Color* pixels, int width, int height); - - /// - /// Reset pixel data with given color. - /// - /// @param color Color to be set. - /// @param width Width of bitmap - /// @param height Height of bitmap - /// - void resetPixels(const Color& color, int width, int height); - - /// - /// Set pixel with given color. - /// - /// @param color Color to be set. - /// @param x X value of pixel. - /// @param y Y value of pixel. - /// - void setPixel(const Color& color, int x, int y); - - /// - /// Set pixels with given color. - /// - /// @param color Color to be set. - /// - void setPixels(Color color); - - /// - /// Set pixels with given color data. - /// - /// @param colors New pixels' colors. - /// @param count Number of pixels. - /// - void setPixels(Color* colors, int count); - - /// - /// Get pixel in given position. - /// - /// @param x X value of position. - /// @param y Y value of position. - /// - Color getPixel(int x, int y); - - /// - /// Get pixels. - /// @return Colors of the bitmap. - /// - const Color* getPixels() const; - - /// - /// Get bitmap width. - /// - /// @return Width of bitmap. - /// - inline int getWidth() const { return width; } - - /// - /// Get bitmap height. - /// - /// @return Height of bitmap. - /// - inline int getHeight() const { return height; } - - /// - /// Get bitmap size. - /// - /// @return Size of bitmap. - /// - inline Math::Vector2<int> getSize() const { return Math::Vector2<int>(width, height); } - - protected: - Color * pixels; - unsigned width, height; - - }; - - } // namespace Graphics + namespace Graphics + { + + /// + /// A RGBA32 bitmap. + /// + /// A bitmap keeps pixels and can't draw directly onto screen. To render bitmap, a texture is required. A + /// texture is a renderable hard ware side structure which could be handled with GPU. For instance, opengl + /// create texture and store it in GPU memory for rendering them onto hdc. + /// + class Bitmap : public Object + { + public: + /// + /// Constructor of bitmap. + /// + Bitmap(); + + /// + /// Constructor of bitmap. + /// + /// @param width Width of bitmap. + /// @param height Height of bitmap. + /// + Bitmap(unsigned w, unsigned h); + + Bitmap(const char* path); + + Bitmap(const void* pixels, unsigned w, unsigned h); + + Bitmap(const void* imgData, size_t size); + + Bitmap(int w, int h, Color color); + + Bitmap(int w, int h, std::function<Color(int, int, int, int)> drawer); + + Bitmap(const Bitmap* bitmap); + + /// + /// Destructor of bitmap + /// + virtual ~Bitmap(); + + /// + /// Create bitmap with another one. + /// + /// @param bitmap Bitmap be cloned. + /// @return Return bitmap pointer if created, otherwise return null. + /// + Bitmap* clone(); + + /// + /// Directly bind pixels with given pixels data + /// + /// @param pixels Pixels to be binded. + /// @param width Width of bitmap + /// @param height Height of bitmap + /// + void bind(Color* pixels, int width, int height); + + /// + /// Reset pixel data with given pixels data. + /// + /// @param pixels Pixels to be set. + /// @param width Width of bitmap + /// @param height Height of bitmap + /// + void resetPixels(const Color* pixels, int width, int height); + + /// + /// Reset pixel data with given color. + /// + /// @param color Color to be set. + /// @param width Width of bitmap + /// @param height Height of bitmap + /// + void resetPixels(const Color& color, int width, int height); + + /// + /// Set pixel with given color. + /// + /// @param color Color to be set. + /// @param x X value of pixel. + /// @param y Y value of pixel. + /// + void setPixel(const Color& color, int x, int y); + + /// + /// Set pixels with given color. + /// + /// @param color Color to be set. + /// + void setPixels(Color color); + + /// + /// Set pixels with given color data. + /// + /// @param colors New pixels' colors. + /// @param count Number of pixels. + /// + void setPixels(Color* colors, int count); + + /// + /// Get pixel in given position. + /// + /// @param x X value of position. + /// @param y Y value of position. + /// + Color getPixel(int x, int y); + + /// + /// Get pixels. + /// @return Colors of the bitmap. + /// + const Color* getPixels() const; + + /// + /// Get bitmap width. + /// + /// @return Width of bitmap. + /// + inline int getWidth() const { return width; } + + /// + /// Get bitmap height. + /// + /// @return Height of bitmap. + /// + inline int getHeight() const { return height; } + + /// + /// Get bitmap size. + /// + /// @return Size of bitmap. + /// + inline Math::Vector2<int> getSize() const { return Math::Vector2<int>(width, height); } + + protected: + Color * pixels; + unsigned width, height; + + }; + + } // namespace Graphics } // namespace JinEngine #endif |