summaryrefslogtreecommitdiffstats
path: root/include/godot_cpp/core/Image.h
blob: 153091059ba55ff4ea20c699ffea51dc1711020c (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#ifndef IMAGE_H
#define IMAGE_H

#include "Defs.h"

#include "Vector2.h"
#include "Rect2.h"
#include "Color.h"
#include "String.h"

#include <godot/godot_image.h>

namespace godot {

class PoolByteArray;

class Image {
	godot_image _godot_image;
public:

	enum Format {

		FORMAT_L8, //luminance
		FORMAT_LA8, //luminance-alpha
		FORMAT_R8,
		FORMAT_RG8,
		FORMAT_RGB8,
		FORMAT_RGBA8,
		FORMAT_RGB565, //16 bit
		FORMAT_RGBA4444,
		FORMAT_RGBA5551,
		FORMAT_RF, //float
		FORMAT_RGF,
		FORMAT_RGBF,
		FORMAT_RGBAF,
		FORMAT_RH, //half float
		FORMAT_RGH,
		FORMAT_RGBH,
		FORMAT_RGBAH,
		FORMAT_DXT1, //s3tc bc1
		FORMAT_DXT3, //bc2
		FORMAT_DXT5, //bc3
		FORMAT_ATI1, //bc4
		FORMAT_ATI2, //bc5
		FORMAT_BPTC_RGBA, //btpc bc6h
		FORMAT_BPTC_RGBF, //float /
		FORMAT_BPTC_RGBFU, //unsigned float
		FORMAT_PVRTC2, //pvrtc
		FORMAT_PVRTC2A,
		FORMAT_PVRTC4,
		FORMAT_PVRTC4A,
		FORMAT_ETC, //etc1
		FORMAT_ETC2_R11, //etc2
		FORMAT_ETC2_R11S, //signed, NOT srgb.
		FORMAT_ETC2_RG11,
		FORMAT_ETC2_RG11S,
		FORMAT_ETC2_RGB8,
		FORMAT_ETC2_RGBA8,
		FORMAT_ETC2_RGB8A1,
		FORMAT_MAX
	};

	enum Interpolation {

		INTERPOLATE_NEAREST,
		INTERPOLATE_BILINEAR,
		INTERPOLATE_CUBIC,
		/* INTERPOLATE GAUSS */
	};

	enum CompressMode {
		COMPRESS_16BIT,
		COMPRESS_S3TC,
		COMPRESS_PVRTC2,
		COMPRESS_PVRTC4,
		COMPRESS_ETC,
		COMPRESS_ETC2
	};


	Image();

	Image(const int width, const int height, const bool mipmaps, const Format format);

	void blit_rect(const Image& src, const Rect2& src_rect, const Vector2& dest = Vector2(0, 0));

	void brush_transfer(const Image& src, const Image& brush, const Vector2& pos = Vector2(0, 0));

	Image brushed(const Image& src, const Image& brush, const Vector2& pos = Vector2(0, 0));

	Image compressed(const Format format);

	Image converted(const Format format);

	Image decompressed();

	bool empty() const;

	void fix_alpha_edges();

	PoolByteArray get_data();


	Format get_format() const;

	int get_height() const;

	Color get_pixel(const int x, const int y, const int mipmap_level = 0);

	Image get_rect(const Rect2& area = Rect2());

	Rect2 get_used_rect() const;

	int get_width() const;

	Error load(const String& path);

	void put_pixel(const int x, const int y, const Color& color, int mipmap_level = 0);

	Image resized(const int x, const int y, const Interpolation interpolation = INTERPOLATE_NEAREST);

	Error save_png(const String& path);

	~Image();
};

}

#endif // IMAGE_H