summaryrefslogtreecommitdiff
path: root/modules/dlscript/godot/godot_image.cpp
diff options
context:
space:
mode:
authorKarroffel <therzog@mail.de>2017-04-03 16:11:38 +0200
committerKarroffel <therzog@mail.de>2017-04-03 17:20:11 +0200
commitfd553087867187220d4f6b8217854dd8e9be2667 (patch)
treeba4c8b2611b1a574056e2f4ae694f18b737ee0e6 /modules/dlscript/godot/godot_image.cpp
parent67f59bc2d9e2ce5faa9507017d49827753981e1e (diff)
added dlscript module
This module was written by bojidar-bg and me, with the help of ClikCode and touilleMan. This adds a module to Godot that enables the use of dynamic libraries as a source for scripts. That also allows third party libraries to be linked to Godot more easily and without creating modules. For a readme see https://github.com/GodotNativeTools/godot_headers/blob/master/README.md
Diffstat (limited to 'modules/dlscript/godot/godot_image.cpp')
-rw-r--r--modules/dlscript/godot/godot_image.cpp85
1 files changed, 85 insertions, 0 deletions
diff --git a/modules/dlscript/godot/godot_image.cpp b/modules/dlscript/godot/godot_image.cpp
new file mode 100644
index 0000000000..362d1aa3e6
--- /dev/null
+++ b/modules/dlscript/godot/godot_image.cpp
@@ -0,0 +1,85 @@
+#include "godot_image.h"
+
+#include "image.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void _image_api_anchor() {
+}
+
+#define memnew_placement_custom(m_placement, m_class, m_constr) _post_initialize(new (m_placement, sizeof(m_class), "") m_constr)
+
+void GDAPI godot_image_new(godot_image *p_img) {
+ Image *img = (Image *)p_img;
+ memnew_placement_custom(img, Image, Image());
+}
+
+void GDAPI godot_image_new_with_png_jpg(godot_image *p_img, const uint8_t *p_mem_png_jpg, int p_len) {
+ Image *img = (Image *)p_img;
+ memnew_placement_custom(img, Image, Image(p_mem_png_jpg, p_len));
+}
+
+void GDAPI godot_image_new_with_xpm(godot_image *p_img, const char **p_xpm) {
+ Image *img = (Image *)p_img;
+ memnew_placement_custom(img, Image, Image(p_xpm));
+}
+
+void GDAPI godot_image_new_with_size_format(godot_image *p_img, int p_width, int p_height, bool p_use_mipmaps, godot_image_format p_format) {
+ Image *img = (Image *)p_img;
+ memnew_placement_custom(img, Image, Image(p_width, p_height, p_use_mipmaps, (Image::Format)p_format));
+}
+
+void GDAPI godot_image_new_with_size_format_data(godot_image *p_img, int p_width, int p_height, bool p_use_mipmaps, godot_image_format p_format, godot_pool_byte_array *p_data) {
+ Image *img = (Image *)p_img;
+ PoolVector<uint8_t> *data = (PoolVector<uint8_t> *)p_data;
+ memnew_placement_custom(img, Image, Image(p_width, p_height, p_use_mipmaps, (Image::Format)p_format, *data));
+}
+
+godot_pool_byte_array GDAPI godot_image_get_data(godot_image *p_img) {
+ Image *img = (Image *)p_img;
+ PoolVector<uint8_t> cpp_data = img->get_data();
+ godot_pool_byte_array *data = (godot_pool_byte_array *)&cpp_data;
+ return *data;
+}
+
+godot_error GDAPI godot_image_load(godot_image *p_img, const godot_string *p_path) {
+ Image *img = (Image *)p_img;
+ String *path = (String *)p_path;
+ return (godot_error)img->load(*path);
+}
+
+godot_error GDAPI godot_image_save_png(godot_image *p_img, const godot_string *p_path) {
+ Image *img = (Image *)p_img;
+ String *path = (String *)p_path;
+ return (godot_error)img->save_png(*path);
+}
+
+int GDAPI godot_image_get_width(const godot_image *p_img) {
+ Image *img = (Image *)p_img;
+ return img->get_width();
+}
+
+int GDAPI godot_image_get_height(const godot_image *p_img) {
+ Image *img = (Image *)p_img;
+ return img->get_height();
+}
+
+godot_bool GDAPI godot_image_has_mipmaps(const godot_image *p_img) {
+ Image *img = (Image *)p_img;
+ return img->has_mipmaps();
+}
+
+int GDAPI godot_image_get_mipmap_count(const godot_image *p_img) {
+ Image *img = (Image *)p_img;
+ return img->get_mipmap_count();
+}
+
+void GDAPI godot_image_destroy(godot_image *p_img) {
+ ((Image *)p_img)->~Image();
+}
+
+#ifdef __cplusplus
+}
+#endif