From bad78945ceba425f6a80e3b8dca2414d592970eb Mon Sep 17 00:00:00 2001 From: chai Date: Fri, 2 Aug 2019 20:51:00 +0800 Subject: =?UTF-8?q?*=E4=BF=AE=E6=94=B9=E6=96=87=E4=BB=B6=E5=90=8D=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/modules/asura-core/Image/ImageData.h | 81 +++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 source/modules/asura-core/Image/ImageData.h (limited to 'source/modules/asura-core/Image/ImageData.h') diff --git a/source/modules/asura-core/Image/ImageData.h b/source/modules/asura-core/Image/ImageData.h new file mode 100644 index 0000000..cd2fe1a --- /dev/null +++ b/source/modules/asura-core/Image/ImageData.h @@ -0,0 +1,81 @@ +#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_begin(AsuraEngine) +namespace_begin(Image) + +class ImageDecoder; + +class ImageData ASURA_FINAL + : public Scripting::Portable + , public AEIO::DecodedData +{ +public: + + /// + /// 解析图片数据文件,并构建像素信息,如果解析失败,抛出异常 + /// + ImageData(); + ~ImageData(); + + void Decode(AEIO::DataBuffer& buffer) override; + + void Lock(); + void Unlock(); + + AEGraphics::Color GetPixel(uint x, uint y); + + //----------------------------------------------------------------------------// + + uint width, height; // 像素尺寸 + AEGraphics::ColorFormat format; // 格式 + byte* pixels; // 像素数据 + std::size_t size; // 数据长度 + + //----------------------------------------------------------------------------// + +private: + + /// + /// 在第一次准备image data时构建所有提供的decoder。在几个decoders中间选择解析策略。 + /// + static std::list ImageDecoders; + + /// + /// 写数据的锁。 + /// + AEThreading::Mutex m_Mutex; + +luaxport: + + LUAX_DECL_FACTORY(ImageData); + + 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); + +}; + +namespace_end +namespace_end + +namespace AEImage = AsuraEngine::Image; + +#endif \ No newline at end of file -- cgit v1.1-26-g67d0