diff options
author | chai <chaifix@163.com> | 2018-10-19 08:36:44 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-10-19 08:36:44 +0800 |
commit | 7d5f055547e70fa93ee9ac944e62f8d657b9dc55 (patch) | |
tree | 081782a1541854db4b8eb69c4b43081f52711286 /src/libjin/Graphics/je_bitmap.h | |
parent | 02dd1f38008594048f0e28bad01e7c6d18844198 (diff) |
*修改文件名
Diffstat (limited to 'src/libjin/Graphics/je_bitmap.h')
-rw-r--r-- | src/libjin/Graphics/je_bitmap.h | 173 |
1 files changed, 173 insertions, 0 deletions
diff --git a/src/libjin/Graphics/je_bitmap.h b/src/libjin/Graphics/je_bitmap.h new file mode 100644 index 0000000..b9747f2 --- /dev/null +++ b/src/libjin/Graphics/je_bitmap.h @@ -0,0 +1,173 @@ +#ifndef __LIBJIN_BITMAP_H +#define __LIBJIN_BITMAP_H +#include "../core/je_configuration.h" +#if LIBJIN_MODULES_RENDER + +#include "../3rdparty/GLee/GLee.h" +#include "../math/je_vector2.hpp" +#include "je_color.h" + +namespace jin +{ + namespace graphics + { + /// + /// A RGBA32 bitmap. + /// + /// A bitmap keeps pixels and can't render directly onto screen. To render bitmap, + /// a texture is required. A texture is create from specific bitmap. + /// + class Bitmap + { + public: + /// + /// Create bitmap by pixels data. + /// + /// @param pixels Pixels data. + /// @param width Width of bitmap. + /// @param height Height of bitmap. + /// @return Return bitmap pointer if created, otherwise return null. + /// + static Bitmap* createBitmap(const void* pixels, unsigned width, unsigned height); + + /// + /// Create bitmap from compressed image data. + /// + /// @param imgData Compressed image data. + /// @param size Size of image data. + /// @return Return bitmap pointer if created, otherwise return null. + /// + static Bitmap* createBitmap(const void* imgData, size_t size); + + /// + /// Create bitmap with specific color and size. + /// + /// @param width Width of bitmap. + /// @param height Height of bitmap. + /// @param color Color of bitmap, black by default. + /// @return Return bitmap pointer if created, otherwise return null. + /// + static Bitmap* createBitmap(int width, int height, Color color = Color::BLACK); + + /// + /// Create bitmap with another one. + /// + /// @param bitmap Bitmap be cloned. + /// @return Return bitmap pointer if created, otherwise return null. + /// + static Bitmap* clone(const Bitmap* bitmap); + + /// + /// Destructor of bitmap + /// + virtual ~Bitmap(); + + /// + /// 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. + /// + void setPixels(Color* colors); + + /// + /// 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: + /// + /// Constructor of bitmap. + /// + Bitmap(); + + /// + /// Constructor of bitmap. + /// + /// @param width Width of bitmap. + /// @param height Height of bitmap. + /// + Bitmap(unsigned w, unsigned h); + + Color * pixels; + unsigned width, height; + + }; + + } // namespace graphics +} // namespace jin + +#endif +#endif
\ No newline at end of file |