From 8644e03586ac9c39741f62cbcbce87b18805538c Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 14 Mar 2019 23:12:54 +0800 Subject: =?UTF-8?q?*=E5=A4=A7=E5=B0=8F=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/Asura.Engine/graphics/image_data.cpp | 50 +++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Source/Asura.Engine/graphics/image_data.cpp (limited to 'Source/Asura.Engine/graphics/image_data.cpp') diff --git a/Source/Asura.Engine/graphics/image_data.cpp b/Source/Asura.Engine/graphics/image_data.cpp new file mode 100644 index 0000000..68781a1 --- /dev/null +++ b/Source/Asura.Engine/graphics/image_data.cpp @@ -0,0 +1,50 @@ +#include "ImageData.h" +#include "PNGDecoder.h" +#include "STBDecoder.h" + +namespace AsuraEngine +{ + namespace Graphics + { + + using namespace std; + + // 解析image的decoder,用来作为解析策略。 + list ImageData::ImageDecoders = { + new PNGDecoder(), // png + new STBDecoder() // jpeg, tga, bmp + }; + + ImageData::ImageData(const Filesystem::DataBuffer& buffer) + : DecodedData(buffer) + { + } + + ImageData::~ImageData() + { + if (pixels) + delete[] pixels; + } + + /// + /// 解析,如果无法成功,抛出异常 + /// + void ImageData::Decode(const Filesystem::DataBuffer& buffer) + { + for (ImageDecoder* decoder : ImageDecoders) + { + if (decoder->CanDecode(buffer)) + { + decoder->Decode(buffer, this); + return; + } + } + } + + Color ImageData::GetPixel(uint x, uint y) + { + + } + + } +} \ No newline at end of file -- cgit v1.1-26-g67d0