aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/Graphics/Image.cpp
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-10-14 22:52:40 +0800
committerchai <chaifix@163.com>2018-10-14 22:52:40 +0800
commitb1bbc998960fff2169dc5a992c47d08723472f9b (patch)
tree220f3bd5de2266e248884e11161dd715d7632ef2 /src/libjin/Graphics/Image.cpp
parentfbf989f9950a38566e0fb0fc5b6a7aebc9f0fb45 (diff)
*直接渲染字符串
Diffstat (limited to 'src/libjin/Graphics/Image.cpp')
-rw-r--r--src/libjin/Graphics/Image.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/libjin/Graphics/Image.cpp b/src/libjin/Graphics/Image.cpp
new file mode 100644
index 0000000..6203395
--- /dev/null
+++ b/src/libjin/Graphics/Image.cpp
@@ -0,0 +1,34 @@
+#include "../3rdparty/stb/stb_image.h"
+#include "Image.h"
+
+namespace jin
+{
+namespace graphics
+{
+
+ /*static*/ Image* Image::createImage(const void* imgData, size_t size)
+ {
+ if (imgData == nullptr)
+ return nullptr;
+ int w, h;
+ void* data = stbi_load_from_memory((unsigned char *)imgData, size, &w, &h, NULL, STBI_rgb_alpha);
+ if (data == nullptr)
+ return nullptr;
+ Image* image = new Image();
+ image->pixels = (Color*)data;
+ image->width = w;
+ image->height = h;
+ return image;
+ }
+
+ Image::Image()
+ : Bitmap()
+ {
+ }
+
+ Image::~Image()
+ {
+ }
+
+}
+}