From 1497dccd63a84b7ee2b229b1ad9c5c02718f2a78 Mon Sep 17 00:00:00 2001 From: chai Date: Tue, 19 Mar 2019 23:06:27 +0800 Subject: *rename --- source/libs/asura-lib-core/graphics/image_data.h | 62 ++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 source/libs/asura-lib-core/graphics/image_data.h (limited to 'source/libs/asura-lib-core/graphics/image_data.h') diff --git a/source/libs/asura-lib-core/graphics/image_data.h b/source/libs/asura-lib-core/graphics/image_data.h new file mode 100644 index 0000000..1e711a8 --- /dev/null +++ b/source/libs/asura-lib-core/graphics/image_data.h @@ -0,0 +1,62 @@ +#ifndef __ASURA_ENGINE_IMAGEDATA_H__ +#define __ASURA_ENGINE_IMAGEDATA_H__ + +#include + +#include "scripting/luax.hpp" +#include "filesystem/decoded_data.h" +#include "image_decoder.h" +#include "pixel_format.h" +#include "color.h" + +namespace AsuraEngine +{ + namespace Graphics + { + + class ImageData ASURA_FINAL + : public Filesystem::DecodedData + , public Scripting::Portable + { + public: + + /// + /// 解析图片数据文件,并构建像素信息,如果解析失败,抛出异常 + /// + ImageData(const Filesystem::DataBuffer& buffer); + + ~ImageData(); + + Color GetPixel(uint x, uint y); + + uint width, height; + PixelFormat format; + std::size_t size; + byte* pixels; + + private: + + void Decode(const Filesystem::DataBuffer& buffer) override; + + /// + /// 在第一次准备image data时构建所有提供的decoder。在几个decoders中间选择解析策略。 + /// + static std::list ImageDecoders; + + public: + + //---------------------------------------------------------------------------------------------------------- + + LUAX_DECL_FACTORY(ImageData); + + LUAX_DECL_METHOD(l_GetPixel); + LUAX_DECL_METHOD(l_GetSize); + + //---------------------------------------------------------------------------------------------------------- + + }; + + } +} + +#endif \ No newline at end of file -- cgit v1.1-26-g67d0