diff options
author | chai <chaifix@163.com> | 2019-01-12 21:48:33 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-01-12 21:48:33 +0800 |
commit | 8b00d67febf133e89f6a0bfabc41feed555dc4a9 (patch) | |
tree | fe48ef17c250afa40c2588300fcdb5920dba6951 /src/libjin/graphics/image.cpp | |
parent | a907c39756ef6b368d06643afa491c49a9044a8e (diff) |
*去掉文件前缀je_
Diffstat (limited to 'src/libjin/graphics/image.cpp')
-rw-r--r-- | src/libjin/graphics/image.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/libjin/graphics/image.cpp b/src/libjin/graphics/image.cpp new file mode 100644 index 0000000..42d717d --- /dev/null +++ b/src/libjin/graphics/image.cpp @@ -0,0 +1,48 @@ +#include "../filesystem/asset_database.h" + +#include "stb/stb_image.h" + +#include "image.h" + +namespace JinEngine +{ + namespace Graphics + { + + using namespace Filesystem; + + Image::Image(const char* path) + : Bitmap() + { + AssetDatabase* fs = AssetDatabase::get(); + Buffer buffer; + fs->read(path, buffer); + Image(&buffer, buffer.size()); + } + + Image::Image(const void* imgData, size_t size) + : Bitmap() + { + if (imgData == nullptr) + return; + int w, h; + void* data = stbi_load_from_memory((uint8*)imgData, size, &w, &h, NULL, STBI_rgb_alpha); + if (data == nullptr) + return; + Image(); + pixels = (Color*)data; + width = w; + height = h; + } + + Image::Image() + : Bitmap() + { + } + + Image::~Image() + { + } + + } // namespace Graphics +} // namespace JinEngine
\ No newline at end of file |