From 250e30d73f09e9da2b5a81d0fbae63744ae12a73 Mon Sep 17 00:00:00 2001 From: chai Date: Tue, 2 Apr 2019 08:47:15 +0800 Subject: *misc --- source/modules/asura-core/image/image_data.h | 85 ++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 source/modules/asura-core/image/image_data.h (limited to 'source/modules/asura-core/image/image_data.h') diff --git a/source/modules/asura-core/image/image_data.h b/source/modules/asura-core/image/image_data.h new file mode 100644 index 0000000..d9427d3 --- /dev/null +++ b/source/modules/asura-core/image/image_data.h @@ -0,0 +1,85 @@ +#ifndef __ASURA_ENGINE_IMAGEDATA_H__ +#define __ASURA_ENGINE_IMAGEDATA_H__ + +#include + +#include +#include +#include +#include +#include + +#include "../graphics/texture.h" +#include "../graphics/color.h" + +namespace AsuraEngine +{ + namespace Graphics + { + + class ImageDecoder; + + class ImageData ASURA_FINAL + : public AEIO::DecodedData + , public Scripting::Portable + { + public: + + LUAX_DECL_FACTORY(ImageData); + + /// + /// 解析图片数据文件,并构建像素信息,如果解析失败,抛出异常 + /// + ImageData(); + ~ImageData(); + + void Decode(AEIO::DataBuffer& buffer) override; + + void Lock(); + void Unlock(); + + Color GetPixel(uint x, uint y); + + //----------------------------------------------------------------------------// + + uint width, height; // 像素尺寸 + ColorFormat format; // 格式 + byte* pixels; // 像素数据 + std::size_t size; // 数据长度 + + //----------------------------------------------------------------------------// + + private: + + //----------------------------------------------------------------------------// + + LUAX_DECL_METHOD(_New); + LUAX_DECL_METHOD(_GetPixel); + LUAX_DECL_METHOD(_GetSize); + LUAX_DECL_METHOD(_GetWidth); + LUAX_DECL_METHOD(_GetHeight); + LUAX_DECL_METHOD(_GetPixelFormat); + LUAX_DECL_METHOD(_Decode); + LUAX_DECL_METHOD(_DecodeAsync); + LUAX_DECL_METHOD(_IsAvailable); + + //----------------------------------------------------------------------------// + + /// + /// 在第一次准备image data时构建所有提供的decoder。在几个decoders中间选择解析策略。 + /// + static std::list ImageDecoders; + + /// + /// 写数据的锁。 + /// + AEThreading::Mutex mMutex; + + }; + + } +} + +namespace AEGraphics = AsuraEngine::Graphics; + +#endif \ No newline at end of file -- cgit v1.1-26-g67d0