1 /**
2 Image datatype.
3 
4 Copyright:
5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur.  
6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md)  
7 Copyright (c) 2017-2018 Godot-D contributors  
8 
9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License)
10 
11 
12 */
13 module godot.image;
14 import std.meta : AliasSeq, staticIndexOf;
15 import std.traits : Unqual;
16 import godot.d.traits;
17 import godot.core;
18 import godot.c;
19 import godot.d.bind;
20 import godot.d.reference;
21 import godot.globalenums;
22 import godot.object;
23 import godot.classdb;
24 import godot.resource;
25 /**
26 Image datatype.
27 
28 Native image datatype. Contains image data which can be converted to an $(D ImageTexture) and provides commonly used $(I image processing) methods. The maximum width and height for an $(D Image) are $(D constant MAX_WIDTH) and $(D constant MAX_HEIGHT).
29 An $(D Image) cannot be assigned to a `texture` property of an object directly (such as $(D Sprite)), and has to be converted manually to an $(D ImageTexture) first.
30 $(B Note:) The maximum image size is 16384×16384 pixels due to graphics hardware limitations. Larger images may fail to import.
31 */
32 @GodotBaseClass struct Image
33 {
34 	package(godot) enum string _GODOT_internal_name = "Image";
35 public:
36 @nogc nothrow:
37 	union { /** */ godot_object _godot_object; /** */ Resource _GODOT_base; }
38 	alias _GODOT_base this;
39 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
40 	package(godot) __gshared bool _classBindingInitialized = false;
41 	package(godot) static struct GDNativeClassBinding
42 	{
43 		__gshared:
44 		@GodotName("_get_data") GodotMethod!(Dictionary) _getData;
45 		@GodotName("_set_data") GodotMethod!(void, Dictionary) _setData;
46 		@GodotName("blend_rect") GodotMethod!(void, Image, Rect2, Vector2) blendRect;
47 		@GodotName("blend_rect_mask") GodotMethod!(void, Image, Image, Rect2, Vector2) blendRectMask;
48 		@GodotName("blit_rect") GodotMethod!(void, Image, Rect2, Vector2) blitRect;
49 		@GodotName("blit_rect_mask") GodotMethod!(void, Image, Image, Rect2, Vector2) blitRectMask;
50 		@GodotName("bumpmap_to_normalmap") GodotMethod!(void, double) bumpmapToNormalmap;
51 		@GodotName("clear_mipmaps") GodotMethod!(void) clearMipmaps;
52 		@GodotName("compress") GodotMethod!(GodotError, long, long, double) compress;
53 		@GodotName("convert") GodotMethod!(void, long) convert;
54 		@GodotName("copy_from") GodotMethod!(void, Image) copyFrom;
55 		@GodotName("create") GodotMethod!(void, long, long, bool, long) create;
56 		@GodotName("create_from_data") GodotMethod!(void, long, long, bool, long, PoolByteArray) createFromData;
57 		@GodotName("crop") GodotMethod!(void, long, long) crop;
58 		@GodotName("decompress") GodotMethod!(GodotError) decompress;
59 		@GodotName("detect_alpha") GodotMethod!(Image.AlphaMode) detectAlpha;
60 		@GodotName("expand_x2_hq2x") GodotMethod!(void) expandX2Hq2x;
61 		@GodotName("fill") GodotMethod!(void, Color) fill;
62 		@GodotName("fix_alpha_edges") GodotMethod!(void) fixAlphaEdges;
63 		@GodotName("flip_x") GodotMethod!(void) flipX;
64 		@GodotName("flip_y") GodotMethod!(void) flipY;
65 		@GodotName("generate_mipmaps") GodotMethod!(GodotError, bool) generateMipmaps;
66 		@GodotName("get_data") GodotMethod!(PoolByteArray) getData;
67 		@GodotName("get_format") GodotMethod!(Image.Format) getFormat;
68 		@GodotName("get_height") GodotMethod!(long) getHeight;
69 		@GodotName("get_mipmap_offset") GodotMethod!(long, long) getMipmapOffset;
70 		@GodotName("get_pixel") GodotMethod!(Color, long, long) getPixel;
71 		@GodotName("get_pixelv") GodotMethod!(Color, Vector2) getPixelv;
72 		@GodotName("get_rect") GodotMethod!(Image, Rect2) getRect;
73 		@GodotName("get_size") GodotMethod!(Vector2) getSize;
74 		@GodotName("get_used_rect") GodotMethod!(Rect2) getUsedRect;
75 		@GodotName("get_width") GodotMethod!(long) getWidth;
76 		@GodotName("has_mipmaps") GodotMethod!(bool) hasMipmaps;
77 		@GodotName("is_compressed") GodotMethod!(bool) isCompressed;
78 		@GodotName("is_empty") GodotMethod!(bool) isEmpty;
79 		@GodotName("is_invisible") GodotMethod!(bool) isInvisible;
80 		@GodotName("load") GodotMethod!(GodotError, String) load;
81 		@GodotName("load_bmp_from_buffer") GodotMethod!(GodotError, PoolByteArray) loadBmpFromBuffer;
82 		@GodotName("load_jpg_from_buffer") GodotMethod!(GodotError, PoolByteArray) loadJpgFromBuffer;
83 		@GodotName("load_png_from_buffer") GodotMethod!(GodotError, PoolByteArray) loadPngFromBuffer;
84 		@GodotName("load_tga_from_buffer") GodotMethod!(GodotError, PoolByteArray) loadTgaFromBuffer;
85 		@GodotName("load_webp_from_buffer") GodotMethod!(GodotError, PoolByteArray) loadWebpFromBuffer;
86 		@GodotName("lock") GodotMethod!(void) lock;
87 		@GodotName("normalmap_to_xy") GodotMethod!(void) normalmapToXy;
88 		@GodotName("premultiply_alpha") GodotMethod!(void) premultiplyAlpha;
89 		@GodotName("resize") GodotMethod!(void, long, long, long) resize;
90 		@GodotName("resize_to_po2") GodotMethod!(void, bool, long) resizeToPo2;
91 		@GodotName("rgbe_to_srgb") GodotMethod!(Image) rgbeToSrgb;
92 		@GodotName("save_exr") GodotMethod!(GodotError, String, bool) saveExr;
93 		@GodotName("save_png") GodotMethod!(GodotError, String) savePng;
94 		@GodotName("save_png_to_buffer") GodotMethod!(PoolByteArray) savePngToBuffer;
95 		@GodotName("set_pixel") GodotMethod!(void, long, long, Color) setPixel;
96 		@GodotName("set_pixelv") GodotMethod!(void, Vector2, Color) setPixelv;
97 		@GodotName("shrink_x2") GodotMethod!(void) shrinkX2;
98 		@GodotName("srgb_to_linear") GodotMethod!(void) srgbToLinear;
99 		@GodotName("unlock") GodotMethod!(void) unlock;
100 	}
101 	/// 
102 	pragma(inline, true) bool opEquals(in Image other) const
103 	{ return _godot_object.ptr is other._godot_object.ptr; }
104 	/// 
105 	pragma(inline, true) typeof(null) opAssign(typeof(null) n)
106 	{ _godot_object.ptr = n; return null; }
107 	/// 
108 	pragma(inline, true) bool opEquals(typeof(null) n) const
109 	{ return _godot_object.ptr is n; }
110 	/// 
111 	size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; }
112 	mixin baseCasts;
113 	/// Construct a new instance of Image.
114 	/// Note: use `memnew!Image` instead.
115 	static Image _new()
116 	{
117 		static godot_class_constructor constructor;
118 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("Image");
119 		if(constructor is null) return typeof(this).init;
120 		return cast(Image)(constructor());
121 	}
122 	@disable new(size_t s);
123 	/// 
124 	enum AlphaMode : int
125 	{
126 		/**
127 		Image does not have alpha.
128 		*/
129 		alphaNone = 0,
130 		/**
131 		Image stores alpha in a single bit.
132 		*/
133 		alphaBit = 1,
134 		/**
135 		Image uses alpha.
136 		*/
137 		alphaBlend = 2,
138 	}
139 	/// 
140 	enum CompressSource : int
141 	{
142 		/**
143 		Source texture (before compression) is a regular texture. Default for all textures.
144 		*/
145 		compressSourceGeneric = 0,
146 		/**
147 		Source texture (before compression) is in sRGB space.
148 		*/
149 		compressSourceSrgb = 1,
150 		/**
151 		Source texture (before compression) is a normal texture (e.g. it can be compressed into two channels).
152 		*/
153 		compressSourceNormal = 2,
154 	}
155 	/// 
156 	enum Interpolation : int
157 	{
158 		/**
159 		Performs nearest-neighbor interpolation. If the image is resized, it will be pixelated.
160 		*/
161 		interpolateNearest = 0,
162 		/**
163 		Performs bilinear interpolation. If the image is resized, it will be blurry. This mode is faster than $(D constant INTERPOLATE_CUBIC), but it results in lower quality.
164 		*/
165 		interpolateBilinear = 1,
166 		/**
167 		Performs cubic interpolation. If the image is resized, it will be blurry. This mode often gives better results compared to $(D constant INTERPOLATE_BILINEAR), at the cost of being slower.
168 		*/
169 		interpolateCubic = 2,
170 		/**
171 		Performs bilinear separately on the two most-suited mipmap levels, then linearly interpolates between them.
172 		It's slower than $(D constant INTERPOLATE_BILINEAR), but produces higher-quality results with far fewer aliasing artifacts.
173 		If the image does not have mipmaps, they will be generated and used internally, but no mipmaps will be generated on the resulting image.
174 		$(B Note:) If you intend to scale multiple copies of the original image, it's better to call $(D generateMipmaps)] on it in advance, to avoid wasting processing power in generating them again and again.
175 		On the other hand, if the image already has mipmaps, they will be used, and a new set will be generated for the resulting image.
176 		*/
177 		interpolateTrilinear = 3,
178 		/**
179 		Performs Lanczos interpolation. This is the slowest image resizing mode, but it typically gives the best results, especially when downscalng images.
180 		*/
181 		interpolateLanczos = 4,
182 	}
183 	/// 
184 	enum CompressMode : int
185 	{
186 		/**
187 		Use S3TC compression.
188 		*/
189 		compressS3tc = 0,
190 		/**
191 		Use PVRTC2 compression.
192 		*/
193 		compressPvrtc2 = 1,
194 		/**
195 		Use PVRTC4 compression.
196 		*/
197 		compressPvrtc4 = 2,
198 		/**
199 		Use ETC compression.
200 		*/
201 		compressEtc = 3,
202 		/**
203 		Use ETC2 compression.
204 		*/
205 		compressEtc2 = 4,
206 	}
207 	/// 
208 	enum Format : int
209 	{
210 		/**
211 		Texture format with a single 8-bit depth representing luminance.
212 		*/
213 		formatL8 = 0,
214 		/**
215 		OpenGL texture format with two values, luminance and alpha each stored with 8 bits.
216 		*/
217 		formatLa8 = 1,
218 		/**
219 		OpenGL texture format `RED` with a single component and a bitdepth of 8.
220 		*/
221 		formatR8 = 2,
222 		/**
223 		OpenGL texture format `RG` with two components and a bitdepth of 8 for each.
224 		*/
225 		formatRg8 = 3,
226 		/**
227 		OpenGL texture format `RGB` with three components, each with a bitdepth of 8.
228 		$(B Note:) When creating an $(D ImageTexture), an sRGB to linear color space conversion is performed.
229 		*/
230 		formatRgb8 = 4,
231 		/**
232 		OpenGL texture format `RGBA` with four components, each with a bitdepth of 8.
233 		$(B Note:) When creating an $(D ImageTexture), an sRGB to linear color space conversion is performed.
234 		*/
235 		formatRgba8 = 5,
236 		/**
237 		OpenGL texture format `RGBA` with four components, each with a bitdepth of 4.
238 		*/
239 		formatRgba4444 = 6,
240 		/**
241 		OpenGL texture format `GL_RGB5_A1` where 5 bits of depth for each component of RGB and one bit for alpha.
242 		*/
243 		formatRgba5551 = 7,
244 		/**
245 		OpenGL texture format `GL_R32F` where there's one component, a 32-bit floating-point value.
246 		*/
247 		formatRf = 8,
248 		/**
249 		OpenGL texture format `GL_RG32F` where there are two components, each a 32-bit floating-point values.
250 		*/
251 		formatRgf = 9,
252 		/**
253 		OpenGL texture format `GL_RGB32F` where there are three components, each a 32-bit floating-point values.
254 		*/
255 		formatRgbf = 10,
256 		/**
257 		OpenGL texture format `GL_RGBA32F` where there are four components, each a 32-bit floating-point values.
258 		*/
259 		formatRgbaf = 11,
260 		/**
261 		OpenGL texture format `GL_R32F` where there's one component, a 16-bit "half-precision" floating-point value.
262 		*/
263 		formatRh = 12,
264 		/**
265 		OpenGL texture format `GL_RG32F` where there are two components, each a 16-bit "half-precision" floating-point value.
266 		*/
267 		formatRgh = 13,
268 		/**
269 		OpenGL texture format `GL_RGB32F` where there are three components, each a 16-bit "half-precision" floating-point value.
270 		*/
271 		formatRgbh = 14,
272 		/**
273 		OpenGL texture format `GL_RGBA32F` where there are four components, each a 16-bit "half-precision" floating-point value.
274 		*/
275 		formatRgbah = 15,
276 		/**
277 		A special OpenGL texture format where the three color components have 9 bits of precision and all three share a single 5-bit exponent.
278 		*/
279 		formatRgbe9995 = 16,
280 		/**
281 		The $(D url=https://en.wikipedia.org/wiki/S3_Texture_Compression)S3TC$(D /url) texture format that uses Block Compression 1, and is the smallest variation of S3TC, only providing 1 bit of alpha and color data being premultiplied with alpha.
282 		$(B Note:) When creating an $(D ImageTexture), an sRGB to linear color space conversion is performed.
283 		*/
284 		formatDxt1 = 17,
285 		/**
286 		The $(D url=https://en.wikipedia.org/wiki/S3_Texture_Compression)S3TC$(D /url) texture format that uses Block Compression 2, and color data is interpreted as not having been premultiplied by alpha. Well suited for images with sharp alpha transitions between translucent and opaque areas.
287 		$(B Note:) When creating an $(D ImageTexture), an sRGB to linear color space conversion is performed.
288 		*/
289 		formatDxt3 = 18,
290 		/**
291 		The $(D url=https://en.wikipedia.org/wiki/S3_Texture_Compression)S3TC$(D /url) texture format also known as Block Compression 3 or BC3 that contains 64 bits of alpha channel data followed by 64 bits of DXT1-encoded color data. Color data is not premultiplied by alpha, same as DXT3. DXT5 generally produces superior results for transparent gradients compared to DXT3.
292 		$(B Note:) When creating an $(D ImageTexture), an sRGB to linear color space conversion is performed.
293 		*/
294 		formatDxt5 = 19,
295 		/**
296 		Texture format that uses $(D url=https://www.khronos.org/opengl/wiki/Red_Green_Texture_Compression)Red Green Texture Compression$(D /url), normalizing the red channel data using the same compression algorithm that DXT5 uses for the alpha channel.
297 		*/
298 		formatRgtcR = 20,
299 		/**
300 		Texture format that uses $(D url=https://www.khronos.org/opengl/wiki/Red_Green_Texture_Compression)Red Green Texture Compression$(D /url), normalizing the red and green channel data using the same compression algorithm that DXT5 uses for the alpha channel.
301 		*/
302 		formatRgtcRg = 21,
303 		/**
304 		Texture format that uses $(D url=https://www.khronos.org/opengl/wiki/BPTC_Texture_Compression)BPTC$(D /url) compression with unsigned normalized RGBA components.
305 		$(B Note:) When creating an $(D ImageTexture), an sRGB to linear color space conversion is performed.
306 		*/
307 		formatBptcRgba = 22,
308 		/**
309 		Texture format that uses $(D url=https://www.khronos.org/opengl/wiki/BPTC_Texture_Compression)BPTC$(D /url) compression with signed floating-point RGB components.
310 		*/
311 		formatBptcRgbf = 23,
312 		/**
313 		Texture format that uses $(D url=https://www.khronos.org/opengl/wiki/BPTC_Texture_Compression)BPTC$(D /url) compression with unsigned floating-point RGB components.
314 		*/
315 		formatBptcRgbfu = 24,
316 		/**
317 		Texture format used on PowerVR-supported mobile platforms, uses 2-bit color depth with no alpha. More information can be found $(D url=https://en.wikipedia.org/wiki/PVRTC)here$(D /url).
318 		$(B Note:) When creating an $(D ImageTexture), an sRGB to linear color space conversion is performed.
319 		*/
320 		formatPvrtc2 = 25,
321 		/**
322 		Same as $(D url=https://en.wikipedia.org/wiki/PVRTC)PVRTC2$(D /url), but with an alpha component.
323 		*/
324 		formatPvrtc2a = 26,
325 		/**
326 		Similar to $(D url=https://en.wikipedia.org/wiki/PVRTC)PVRTC2$(D /url), but with 4-bit color depth and no alpha.
327 		*/
328 		formatPvrtc4 = 27,
329 		/**
330 		Same as $(D url=https://en.wikipedia.org/wiki/PVRTC)PVRTC4$(D /url), but with an alpha component.
331 		*/
332 		formatPvrtc4a = 28,
333 		/**
334 		$(D url=https://en.wikipedia.org/wiki/Ericsson_Texture_Compression#ETC1)Ericsson Texture Compression format 1$(D /url), also referred to as "ETC1", and is part of the OpenGL ES graphics standard. This format cannot store an alpha channel.
335 		*/
336 		formatEtc = 29,
337 		/**
338 		$(D url=https://en.wikipedia.org/wiki/Ericsson_Texture_Compression#ETC2_and_EAC)Ericsson Texture Compression format 2$(D /url) (`R11_EAC` variant), which provides one channel of unsigned data.
339 		*/
340 		formatEtc2R11 = 30,
341 		/**
342 		$(D url=https://en.wikipedia.org/wiki/Ericsson_Texture_Compression#ETC2_and_EAC)Ericsson Texture Compression format 2$(D /url) (`SIGNED_R11_EAC` variant), which provides one channel of signed data.
343 		*/
344 		formatEtc2R11s = 31,
345 		/**
346 		$(D url=https://en.wikipedia.org/wiki/Ericsson_Texture_Compression#ETC2_and_EAC)Ericsson Texture Compression format 2$(D /url) (`RG11_EAC` variant), which provides two channels of unsigned data.
347 		*/
348 		formatEtc2Rg11 = 32,
349 		/**
350 		$(D url=https://en.wikipedia.org/wiki/Ericsson_Texture_Compression#ETC2_and_EAC)Ericsson Texture Compression format 2$(D /url) (`SIGNED_RG11_EAC` variant), which provides two channels of signed data.
351 		*/
352 		formatEtc2Rg11s = 33,
353 		/**
354 		$(D url=https://en.wikipedia.org/wiki/Ericsson_Texture_Compression#ETC2_and_EAC)Ericsson Texture Compression format 2$(D /url) (`RGB8` variant), which is a follow-up of ETC1 and compresses RGB888 data.
355 		$(B Note:) When creating an $(D ImageTexture), an sRGB to linear color space conversion is performed.
356 		*/
357 		formatEtc2Rgb8 = 34,
358 		/**
359 		$(D url=https://en.wikipedia.org/wiki/Ericsson_Texture_Compression#ETC2_and_EAC)Ericsson Texture Compression format 2$(D /url) (`RGBA8`variant), which compresses RGBA8888 data with full alpha support.
360 		$(B Note:) When creating an $(D ImageTexture), an sRGB to linear color space conversion is performed.
361 		*/
362 		formatEtc2Rgba8 = 35,
363 		/**
364 		$(D url=https://en.wikipedia.org/wiki/Ericsson_Texture_Compression#ETC2_and_EAC)Ericsson Texture Compression format 2$(D /url) (`RGB8_PUNCHTHROUGH_ALPHA1` variant), which compresses RGBA data to make alpha either fully transparent or fully opaque.
365 		$(B Note:) When creating an $(D ImageTexture), an sRGB to linear color space conversion is performed.
366 		*/
367 		formatEtc2Rgb8a1 = 36,
368 		/**
369 		Represents the size of the $(D format) enum.
370 		*/
371 		formatMax = 37,
372 	}
373 	/// 
374 	enum Constants : int
375 	{
376 		interpolateNearest = 0,
377 		formatL8 = 0,
378 		alphaNone = 0,
379 		compressS3tc = 0,
380 		compressSourceGeneric = 0,
381 		compressSourceSrgb = 1,
382 		alphaBit = 1,
383 		interpolateBilinear = 1,
384 		formatLa8 = 1,
385 		compressPvrtc2 = 1,
386 		compressSourceNormal = 2,
387 		interpolateCubic = 2,
388 		formatR8 = 2,
389 		compressPvrtc4 = 2,
390 		alphaBlend = 2,
391 		compressEtc = 3,
392 		formatRg8 = 3,
393 		interpolateTrilinear = 3,
394 		interpolateLanczos = 4,
395 		formatRgb8 = 4,
396 		compressEtc2 = 4,
397 		formatRgba8 = 5,
398 		formatRgba4444 = 6,
399 		formatRgba5551 = 7,
400 		formatRf = 8,
401 		formatRgf = 9,
402 		formatRgbf = 10,
403 		formatRgbaf = 11,
404 		formatRh = 12,
405 		formatRgh = 13,
406 		formatRgbh = 14,
407 		formatRgbah = 15,
408 		formatRgbe9995 = 16,
409 		formatDxt1 = 17,
410 		formatDxt3 = 18,
411 		formatDxt5 = 19,
412 		formatRgtcR = 20,
413 		formatRgtcRg = 21,
414 		formatBptcRgba = 22,
415 		formatBptcRgbf = 23,
416 		formatBptcRgbfu = 24,
417 		formatPvrtc2 = 25,
418 		formatPvrtc2a = 26,
419 		formatPvrtc4 = 27,
420 		formatPvrtc4a = 28,
421 		formatEtc = 29,
422 		formatEtc2R11 = 30,
423 		formatEtc2R11s = 31,
424 		formatEtc2Rg11 = 32,
425 		formatEtc2Rg11s = 33,
426 		formatEtc2Rgb8 = 34,
427 		formatEtc2Rgba8 = 35,
428 		formatEtc2Rgb8a1 = 36,
429 		formatMax = 37,
430 		/**
431 		The maximal height allowed for $(D Image) resources.
432 		*/
433 		maxHeight = 16384,
434 		/**
435 		The maximal width allowed for $(D Image) resources.
436 		*/
437 		maxWidth = 16384,
438 	}
439 	/**
440 	
441 	*/
442 	Dictionary _getData() const
443 	{
444 		Array _GODOT_args = Array.make();
445 		String _GODOT_method_name = String("_get_data");
446 		return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!Dictionary);
447 	}
448 	/**
449 	
450 	*/
451 	void _setData(in Dictionary data)
452 	{
453 		Array _GODOT_args = Array.make();
454 		_GODOT_args.append(data);
455 		String _GODOT_method_name = String("_set_data");
456 		this.callv(_GODOT_method_name, _GODOT_args);
457 	}
458 	/**
459 	Alpha-blends `src_rect` from `src` image to this image at coordinates `dest`.
460 	*/
461 	void blendRect(Image src, in Rect2 src_rect, in Vector2 dst)
462 	{
463 		checkClassBinding!(typeof(this))();
464 		ptrcall!(void)(GDNativeClassBinding.blendRect, _godot_object, src, src_rect, dst);
465 	}
466 	/**
467 	Alpha-blends `src_rect` from `src` image to this image using `mask` image at coordinates `dst`. Alpha channels are required for both `src` and `mask`. `dst` pixels and `src` pixels will blend if the corresponding mask pixel's alpha value is not 0. `src` image and `mask` image $(B must) have the same size (width and height) but they can have different formats.
468 	*/
469 	void blendRectMask(Image src, Image mask, in Rect2 src_rect, in Vector2 dst)
470 	{
471 		checkClassBinding!(typeof(this))();
472 		ptrcall!(void)(GDNativeClassBinding.blendRectMask, _godot_object, src, mask, src_rect, dst);
473 	}
474 	/**
475 	Copies `src_rect` from `src` image to this image at coordinates `dst`.
476 	*/
477 	void blitRect(Image src, in Rect2 src_rect, in Vector2 dst)
478 	{
479 		checkClassBinding!(typeof(this))();
480 		ptrcall!(void)(GDNativeClassBinding.blitRect, _godot_object, src, src_rect, dst);
481 	}
482 	/**
483 	Blits `src_rect` area from `src` image to this image at the coordinates given by `dst`. `src` pixel is copied onto `dst` if the corresponding `mask` pixel's alpha value is not 0. `src` image and `mask` image $(B must) have the same size (width and height) but they can have different formats.
484 	*/
485 	void blitRectMask(Image src, Image mask, in Rect2 src_rect, in Vector2 dst)
486 	{
487 		checkClassBinding!(typeof(this))();
488 		ptrcall!(void)(GDNativeClassBinding.blitRectMask, _godot_object, src, mask, src_rect, dst);
489 	}
490 	/**
491 	Converts a bumpmap to a normalmap. A bumpmap provides a height offset per-pixel, while a normalmap provides a normal direction per pixel.
492 	*/
493 	void bumpmapToNormalmap(in double bump_scale = 1)
494 	{
495 		checkClassBinding!(typeof(this))();
496 		ptrcall!(void)(GDNativeClassBinding.bumpmapToNormalmap, _godot_object, bump_scale);
497 	}
498 	/**
499 	Removes the image's mipmaps.
500 	*/
501 	void clearMipmaps()
502 	{
503 		checkClassBinding!(typeof(this))();
504 		ptrcall!(void)(GDNativeClassBinding.clearMipmaps, _godot_object);
505 	}
506 	/**
507 	Compresses the image to use less memory. Can not directly access pixel data while the image is compressed. Returns error if the chosen compression mode is not available. See $(D compressmode) and $(D compresssource) constants.
508 	*/
509 	GodotError compress(in long mode, in long source, in double lossy_quality)
510 	{
511 		checkClassBinding!(typeof(this))();
512 		return ptrcall!(GodotError)(GDNativeClassBinding.compress, _godot_object, mode, source, lossy_quality);
513 	}
514 	/**
515 	Converts the image's format. See $(D format) constants.
516 	*/
517 	void convert(in long format)
518 	{
519 		checkClassBinding!(typeof(this))();
520 		ptrcall!(void)(GDNativeClassBinding.convert, _godot_object, format);
521 	}
522 	/**
523 	Copies `src` image to this image.
524 	*/
525 	void copyFrom(Image src)
526 	{
527 		checkClassBinding!(typeof(this))();
528 		ptrcall!(void)(GDNativeClassBinding.copyFrom, _godot_object, src);
529 	}
530 	/**
531 	Creates an empty image of given size and format. See $(D format) constants. If `use_mipmaps` is `true` then generate mipmaps for this image. See the $(D generateMipmaps).
532 	*/
533 	void create(in long width, in long height, in bool use_mipmaps, in long format)
534 	{
535 		checkClassBinding!(typeof(this))();
536 		ptrcall!(void)(GDNativeClassBinding.create, _godot_object, width, height, use_mipmaps, format);
537 	}
538 	/**
539 	Creates a new image of given size and format. See $(D format) constants. Fills the image with the given raw data. If `use_mipmaps` is `true` then loads mipmaps for this image from `data`. See $(D generateMipmaps).
540 	*/
541 	void createFromData(in long width, in long height, in bool use_mipmaps, in long format, in PoolByteArray data)
542 	{
543 		checkClassBinding!(typeof(this))();
544 		ptrcall!(void)(GDNativeClassBinding.createFromData, _godot_object, width, height, use_mipmaps, format, data);
545 	}
546 	/**
547 	Crops the image to the given `width` and `height`. If the specified size is larger than the current size, the extra area is filled with black pixels.
548 	*/
549 	void crop(in long width, in long height)
550 	{
551 		checkClassBinding!(typeof(this))();
552 		ptrcall!(void)(GDNativeClassBinding.crop, _godot_object, width, height);
553 	}
554 	/**
555 	Decompresses the image if it is compressed. Returns an error if decompress function is not available.
556 	*/
557 	GodotError decompress()
558 	{
559 		checkClassBinding!(typeof(this))();
560 		return ptrcall!(GodotError)(GDNativeClassBinding.decompress, _godot_object);
561 	}
562 	/**
563 	Returns $(D constant ALPHA_BLEND) if the image has data for alpha values. Returns $(D constant ALPHA_BIT) if all the alpha values are stored in a single bit. Returns $(D constant ALPHA_NONE) if no data for alpha values is found.
564 	*/
565 	Image.AlphaMode detectAlpha() const
566 	{
567 		checkClassBinding!(typeof(this))();
568 		return ptrcall!(Image.AlphaMode)(GDNativeClassBinding.detectAlpha, _godot_object);
569 	}
570 	/**
571 	Stretches the image and enlarges it by a factor of 2. No interpolation is done.
572 	*/
573 	void expandX2Hq2x()
574 	{
575 		checkClassBinding!(typeof(this))();
576 		ptrcall!(void)(GDNativeClassBinding.expandX2Hq2x, _godot_object);
577 	}
578 	/**
579 	Fills the image with a given $(D Color).
580 	*/
581 	void fill(in Color color)
582 	{
583 		checkClassBinding!(typeof(this))();
584 		ptrcall!(void)(GDNativeClassBinding.fill, _godot_object, color);
585 	}
586 	/**
587 	Blends low-alpha pixels with nearby pixels.
588 	*/
589 	void fixAlphaEdges()
590 	{
591 		checkClassBinding!(typeof(this))();
592 		ptrcall!(void)(GDNativeClassBinding.fixAlphaEdges, _godot_object);
593 	}
594 	/**
595 	Flips the image horizontally.
596 	*/
597 	void flipX()
598 	{
599 		checkClassBinding!(typeof(this))();
600 		ptrcall!(void)(GDNativeClassBinding.flipX, _godot_object);
601 	}
602 	/**
603 	Flips the image vertically.
604 	*/
605 	void flipY()
606 	{
607 		checkClassBinding!(typeof(this))();
608 		ptrcall!(void)(GDNativeClassBinding.flipY, _godot_object);
609 	}
610 	/**
611 	Generates mipmaps for the image. Mipmaps are precalculated lower-resolution copies of the image that are automatically used if the image needs to be scaled down when rendered. They help improve image quality and performance when rendering. This method returns an error if the image is compressed, in a custom format, or if the image's width/height is `0`.
612 	*/
613 	GodotError generateMipmaps(in bool renormalize = false)
614 	{
615 		checkClassBinding!(typeof(this))();
616 		return ptrcall!(GodotError)(GDNativeClassBinding.generateMipmaps, _godot_object, renormalize);
617 	}
618 	/**
619 	Returns a copy of the image's raw data.
620 	*/
621 	PoolByteArray getData() const
622 	{
623 		checkClassBinding!(typeof(this))();
624 		return ptrcall!(PoolByteArray)(GDNativeClassBinding.getData, _godot_object);
625 	}
626 	/**
627 	Returns the image's format. See $(D format) constants.
628 	*/
629 	Image.Format getFormat() const
630 	{
631 		checkClassBinding!(typeof(this))();
632 		return ptrcall!(Image.Format)(GDNativeClassBinding.getFormat, _godot_object);
633 	}
634 	/**
635 	Returns the image's height.
636 	*/
637 	long getHeight() const
638 	{
639 		checkClassBinding!(typeof(this))();
640 		return ptrcall!(long)(GDNativeClassBinding.getHeight, _godot_object);
641 	}
642 	/**
643 	Returns the offset where the image's mipmap with index `mipmap` is stored in the `data` dictionary.
644 	*/
645 	long getMipmapOffset(in long mipmap) const
646 	{
647 		checkClassBinding!(typeof(this))();
648 		return ptrcall!(long)(GDNativeClassBinding.getMipmapOffset, _godot_object, mipmap);
649 	}
650 	/**
651 	Returns the color of the pixel at `(x, y)` if the image is locked. If the image is unlocked, it always returns a $(D Color) with the value `(0, 0, 0, 1.0)`. This is the same as $(D getPixelv), but two integer arguments instead of a Vector2 argument.
652 	*/
653 	Color getPixel(in long x, in long y) const
654 	{
655 		checkClassBinding!(typeof(this))();
656 		return ptrcall!(Color)(GDNativeClassBinding.getPixel, _godot_object, x, y);
657 	}
658 	/**
659 	Returns the color of the pixel at `src` if the image is locked. If the image is unlocked, it always returns a $(D Color) with the value `(0, 0, 0, 1.0)`. This is the same as $(D getPixel), but with a Vector2 argument instead of two integer arguments.
660 	*/
661 	Color getPixelv(in Vector2 src) const
662 	{
663 		checkClassBinding!(typeof(this))();
664 		return ptrcall!(Color)(GDNativeClassBinding.getPixelv, _godot_object, src);
665 	}
666 	/**
667 	Returns a new image that is a copy of the image's area specified with `rect`.
668 	*/
669 	Ref!Image getRect(in Rect2 rect) const
670 	{
671 		checkClassBinding!(typeof(this))();
672 		return ptrcall!(Image)(GDNativeClassBinding.getRect, _godot_object, rect);
673 	}
674 	/**
675 	Returns the image's size (width and height).
676 	*/
677 	Vector2 getSize() const
678 	{
679 		checkClassBinding!(typeof(this))();
680 		return ptrcall!(Vector2)(GDNativeClassBinding.getSize, _godot_object);
681 	}
682 	/**
683 	Returns a $(D Rect2) enclosing the visible portion of the image, considering each pixel with a non-zero alpha channel as visible.
684 	*/
685 	Rect2 getUsedRect() const
686 	{
687 		checkClassBinding!(typeof(this))();
688 		return ptrcall!(Rect2)(GDNativeClassBinding.getUsedRect, _godot_object);
689 	}
690 	/**
691 	Returns the image's width.
692 	*/
693 	long getWidth() const
694 	{
695 		checkClassBinding!(typeof(this))();
696 		return ptrcall!(long)(GDNativeClassBinding.getWidth, _godot_object);
697 	}
698 	/**
699 	Returns `true` if the image has generated mipmaps.
700 	*/
701 	bool hasMipmaps() const
702 	{
703 		checkClassBinding!(typeof(this))();
704 		return ptrcall!(bool)(GDNativeClassBinding.hasMipmaps, _godot_object);
705 	}
706 	/**
707 	Returns `true` if the image is compressed.
708 	*/
709 	bool isCompressed() const
710 	{
711 		checkClassBinding!(typeof(this))();
712 		return ptrcall!(bool)(GDNativeClassBinding.isCompressed, _godot_object);
713 	}
714 	/**
715 	Returns `true` if the image has no data.
716 	*/
717 	bool isEmpty() const
718 	{
719 		checkClassBinding!(typeof(this))();
720 		return ptrcall!(bool)(GDNativeClassBinding.isEmpty, _godot_object);
721 	}
722 	/**
723 	Returns `true` if all the image's pixels have an alpha value of 0. Returns `false` if any pixel has an alpha value higher than 0.
724 	*/
725 	bool isInvisible() const
726 	{
727 		checkClassBinding!(typeof(this))();
728 		return ptrcall!(bool)(GDNativeClassBinding.isInvisible, _godot_object);
729 	}
730 	/**
731 	Loads an image from file `path`. See $(D url=https://docs.godotengine.org/en/3.3/getting_started/workflow/assets/importing_images.html#supported-image-formats)Supported image formats$(D /url) for a list of supported image formats and limitations.
732 	$(B Warning:) This method should only be used in the editor or in cases when you need to load external images at run-time, such as images located at the `user://` directory, and may not work in exported projects.
733 	See also $(D ImageTexture) description for usage examples.
734 	*/
735 	GodotError load(in String path)
736 	{
737 		checkClassBinding!(typeof(this))();
738 		return ptrcall!(GodotError)(GDNativeClassBinding.load, _godot_object, path);
739 	}
740 	/**
741 	Loads an image from the binary contents of a BMP file.
742 	$(B Note:) Godot's BMP module doesn't support 16-bit per pixel images. Only 1-bit, 4-bit, 8-bit, 24-bit, and 32-bit per pixel images are supported.
743 	*/
744 	GodotError loadBmpFromBuffer(in PoolByteArray buffer)
745 	{
746 		checkClassBinding!(typeof(this))();
747 		return ptrcall!(GodotError)(GDNativeClassBinding.loadBmpFromBuffer, _godot_object, buffer);
748 	}
749 	/**
750 	Loads an image from the binary contents of a JPEG file.
751 	*/
752 	GodotError loadJpgFromBuffer(in PoolByteArray buffer)
753 	{
754 		checkClassBinding!(typeof(this))();
755 		return ptrcall!(GodotError)(GDNativeClassBinding.loadJpgFromBuffer, _godot_object, buffer);
756 	}
757 	/**
758 	Loads an image from the binary contents of a PNG file.
759 	*/
760 	GodotError loadPngFromBuffer(in PoolByteArray buffer)
761 	{
762 		checkClassBinding!(typeof(this))();
763 		return ptrcall!(GodotError)(GDNativeClassBinding.loadPngFromBuffer, _godot_object, buffer);
764 	}
765 	/**
766 	Loads an image from the binary contents of a TGA file.
767 	*/
768 	GodotError loadTgaFromBuffer(in PoolByteArray buffer)
769 	{
770 		checkClassBinding!(typeof(this))();
771 		return ptrcall!(GodotError)(GDNativeClassBinding.loadTgaFromBuffer, _godot_object, buffer);
772 	}
773 	/**
774 	Loads an image from the binary contents of a WebP file.
775 	*/
776 	GodotError loadWebpFromBuffer(in PoolByteArray buffer)
777 	{
778 		checkClassBinding!(typeof(this))();
779 		return ptrcall!(GodotError)(GDNativeClassBinding.loadWebpFromBuffer, _godot_object, buffer);
780 	}
781 	/**
782 	Locks the data for reading and writing access. Sends an error to the console if the image is not locked when reading or writing a pixel.
783 	*/
784 	void lock()
785 	{
786 		checkClassBinding!(typeof(this))();
787 		ptrcall!(void)(GDNativeClassBinding.lock, _godot_object);
788 	}
789 	/**
790 	Converts the image's data to represent coordinates on a 3D plane. This is used when the image represents a normalmap. A normalmap can add lots of detail to a 3D surface without increasing the polygon count.
791 	*/
792 	void normalmapToXy()
793 	{
794 		checkClassBinding!(typeof(this))();
795 		ptrcall!(void)(GDNativeClassBinding.normalmapToXy, _godot_object);
796 	}
797 	/**
798 	Multiplies color values with alpha values. Resulting color values for a pixel are `(color * alpha)/256`.
799 	*/
800 	void premultiplyAlpha()
801 	{
802 		checkClassBinding!(typeof(this))();
803 		ptrcall!(void)(GDNativeClassBinding.premultiplyAlpha, _godot_object);
804 	}
805 	/**
806 	Resizes the image to the given `width` and `height`. New pixels are calculated using the `interpolation` mode defined via $(D interpolation) constants.
807 	*/
808 	void resize(in long width, in long height, in long interpolation = 1)
809 	{
810 		checkClassBinding!(typeof(this))();
811 		ptrcall!(void)(GDNativeClassBinding.resize, _godot_object, width, height, interpolation);
812 	}
813 	/**
814 	Resizes the image to the nearest power of 2 for the width and height. If `square` is `true` then set width and height to be the same. New pixels are calculated using the `interpolation` mode defined via $(D interpolation) constants.
815 	*/
816 	void resizeToPo2(in bool square = false, in long interpolation = 1)
817 	{
818 		checkClassBinding!(typeof(this))();
819 		ptrcall!(void)(GDNativeClassBinding.resizeToPo2, _godot_object, square, interpolation);
820 	}
821 	/**
822 	Converts a standard RGBE (Red Green Blue Exponent) image to an sRGB image.
823 	*/
824 	Ref!Image rgbeToSrgb()
825 	{
826 		checkClassBinding!(typeof(this))();
827 		return ptrcall!(Image)(GDNativeClassBinding.rgbeToSrgb, _godot_object);
828 	}
829 	/**
830 	Saves the image as an EXR file to `path`. If `grayscale` is `true` and the image has only one channel, it will be saved explicitly as monochrome rather than one red channel. This function will return $(D constant ERR_UNAVAILABLE) if Godot was compiled without the TinyEXR module.
831 	$(B Note:) The TinyEXR module is disabled in non-editor builds, which means $(D saveExr) will return $(D constant ERR_UNAVAILABLE) when it is called from an exported project.
832 	*/
833 	GodotError saveExr(in String path, in bool grayscale = false) const
834 	{
835 		checkClassBinding!(typeof(this))();
836 		return ptrcall!(GodotError)(GDNativeClassBinding.saveExr, _godot_object, path, grayscale);
837 	}
838 	/**
839 	Saves the image as a PNG file to `path`.
840 	*/
841 	GodotError savePng(in String path) const
842 	{
843 		checkClassBinding!(typeof(this))();
844 		return ptrcall!(GodotError)(GDNativeClassBinding.savePng, _godot_object, path);
845 	}
846 	/**
847 	
848 	*/
849 	PoolByteArray savePngToBuffer() const
850 	{
851 		checkClassBinding!(typeof(this))();
852 		return ptrcall!(PoolByteArray)(GDNativeClassBinding.savePngToBuffer, _godot_object);
853 	}
854 	/**
855 	Sets the $(D Color) of the pixel at `(x, y)` if the image is locked. Example:
856 	
857 	
858 	var img = Image.new()
859 	img.create(img_width, img_height, false, Image.FORMAT_RGBA8)
860 	img.lock()
861 	img.set_pixel(x, y, color) # Works
862 	img.unlock()
863 	img.set_pixel(x, y, color) # Does not have an effect
864 	
865 	
866 	*/
867 	void setPixel(in long x, in long y, in Color color)
868 	{
869 		checkClassBinding!(typeof(this))();
870 		ptrcall!(void)(GDNativeClassBinding.setPixel, _godot_object, x, y, color);
871 	}
872 	/**
873 	Sets the $(D Color) of the pixel at `(dst.x, dst.y)` if the image is locked. Note that the `dst` values must be integers. Example:
874 	
875 	
876 	var img = Image.new()
877 	img.create(img_width, img_height, false, Image.FORMAT_RGBA8)
878 	img.lock()
879 	img.set_pixelv(Vector2(x, y), color) # Works
880 	img.unlock()
881 	img.set_pixelv(Vector2(x, y), color) # Does not have an effect
882 	
883 	
884 	*/
885 	void setPixelv(in Vector2 dst, in Color color)
886 	{
887 		checkClassBinding!(typeof(this))();
888 		ptrcall!(void)(GDNativeClassBinding.setPixelv, _godot_object, dst, color);
889 	}
890 	/**
891 	Shrinks the image by a factor of 2.
892 	*/
893 	void shrinkX2()
894 	{
895 		checkClassBinding!(typeof(this))();
896 		ptrcall!(void)(GDNativeClassBinding.shrinkX2, _godot_object);
897 	}
898 	/**
899 	Converts the raw data from the sRGB colorspace to a linear scale.
900 	*/
901 	void srgbToLinear()
902 	{
903 		checkClassBinding!(typeof(this))();
904 		ptrcall!(void)(GDNativeClassBinding.srgbToLinear, _godot_object);
905 	}
906 	/**
907 	Unlocks the data and prevents changes.
908 	*/
909 	void unlock()
910 	{
911 		checkClassBinding!(typeof(this))();
912 		ptrcall!(void)(GDNativeClassBinding.unlock, _godot_object);
913 	}
914 	/**
915 	Holds all the image's color data in a given format. See $(D format) constants.
916 	*/
917 	@property Dictionary data()
918 	{
919 		return _getData();
920 	}
921 	/// ditto
922 	@property void data(Dictionary v)
923 	{
924 		_setData(v);
925 	}
926 }