aboutsummaryrefslogtreecommitdiff
path: root/src/graphics/Image.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/graphics/Image.cpp')
-rw-r--r--src/graphics/Image.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/graphics/Image.cpp b/src/graphics/Image.cpp
new file mode 100644
index 0000000..4c9a222
--- /dev/null
+++ b/src/graphics/Image.cpp
@@ -0,0 +1,34 @@
+#include "../../include/mglpp/graphics/Image.hpp"
+#include <string.h>
+
+namespace mgl {
+ Image::Image() {
+ memset(&image, 0, sizeof(image));
+ }
+
+ Image::~Image() {
+ mgl_image_unload(&image);
+ }
+
+ bool Image::load_from_file(const char *filepath) {
+ if(image.data)
+ return false;
+ return mgl_image_load_from_file(&image, filepath) == 0;
+ }
+
+ unsigned char* Image::data() {
+ return image.data;
+ }
+
+ size_t Image::byte_size() {
+ return mgl_image_get_size(&image);
+ }
+
+ vec2i Image::size() const {
+ return { image.width, image.height };
+ }
+
+ mgl_image* Image::internal_image() {
+ return &image;
+ }
+} \ No newline at end of file