From c302f5ae5f9e30a28e487e8a764d9cc31546bbea Mon Sep 17 00:00:00 2001 From: chai Date: Fri, 29 Mar 2019 22:51:04 +0800 Subject: *rename --- source/modules/asura-core/graphics/image_data.h | 68 +++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 source/modules/asura-core/graphics/image_data.h (limited to 'source/modules/asura-core/graphics/image_data.h') diff --git a/source/modules/asura-core/graphics/image_data.h b/source/modules/asura-core/graphics/image_data.h new file mode 100644 index 0000000..ea1d53a --- /dev/null +++ b/source/modules/asura-core/graphics/image_data.h @@ -0,0 +1,68 @@ +#ifndef __ASURA_ENGINE_IMAGEDATA_H__ +#define __ASURA_ENGINE_IMAGEDATA_H__ + +#include + +#include +#include +#include +#include + +#include "pixel_format.h" +#include "color.h" + +namespace AsuraEngine +{ + namespace Graphics + { + + class ImageDecoder; + + class ImageData ASURA_FINAL + : public AEIO::DecodedData + , public Scripting::Portable + { + public: + + LUAX_DECL_FACTORY(ImageData); + + /// + /// 解析图片数据文件,并构建像素信息,如果解析失败,抛出异常 + /// + ImageData(const AEIO::DataBuffer& buffer); + ~ImageData(); + + void Load(const AEIO::DataBuffer& buffer); + void LoadAsync(const AEIO::DataBuffer& buffer, AEThreading::Thread* thread); + + Color GetPixel(uint x, uint y); + + uint width, height; + PixelFormat format; + std::size_t size; + byte* pixels; + + private: + + void Decode(const AEIO::DataBuffer& buffer) override; + + /// + /// 在第一次准备image data时构建所有提供的decoder。在几个decoders中间选择解析策略。 + /// + static std::list ImageDecoders; + + LUAX_DECL_METHOD(_New); + LUAX_DECL_METHOD(_GetPixel); + LUAX_DECL_METHOD(_GetSize); + LUAX_DECL_METHOD(_GetWidth); + LUAX_DECL_METHOD(_GetHeight); + LUAX_DECL_METHOD(_GetPixelFormat); + + }; + + } +} + +namespace AEGraphics = AsuraEngine::Graphics; + +#endif \ No newline at end of file -- cgit v1.1-26-g67d0