aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/Graphics/Bitmap.h
blob: 553d9994de43644822df18c207ad6799d25ffb1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef __LIBJIN_BITMAP_H
#define __LIBJIN_BITMAP_H
#include "../jin_configuration.h"
#if LIBJIN_MODULES_RENDER

#include "../Math/Vector2.hpp"
#include "../3rdparty/GLee/GLee.h"
#include "Color.h"

namespace jin
{
namespace graphics
{

    class Bitmap
    {
    public:
        static Bitmap* createBitmap(const void* imgData, size_t size);
        static Bitmap* createBitmap(int w, int h, Color color = Color::BLACK);
        static Bitmap* clone(const Bitmap* bitmap);

        virtual ~Bitmap();
        /* init pixels */
        void bind(Color* pixels, int w, int h);
        void resetPixels(const Color* pixels, int w, int h);
        void resetPixels(const Color& pixels, int w, int h);
        /* modify pixels */
        void setPixel(const Color& pixel, int x, int y);
        void setPixels(Color pixels);
        void setPixels(Color* pixels);
        Color getPixel(int x, int y);
        const Color* getPixels() const;
        /* get width and height */
        inline int getWidth() const { return width; }
        inline int getHeight() const { return height; }
		inline math::Vector2<int> getSize() const { return math::Vector2<int>(width, height); }

    protected:
        Bitmap();
        Bitmap(int w, int h);

        Color * pixels;
        int width, height;

    };

} // graphics
} // jin

#endif
#endif