summaryrefslogtreecommitdiff
path: root/Source/Asura.Engine/Graphics/STBDecoder.cpp
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2019-03-12 00:39:26 +0800
committerchai <chaifix@163.com>2019-03-12 00:39:26 +0800
commit70b82d1981c0de3c7b77670ff8abcfeb26815142 (patch)
treef69c05bcd204cc3f9bf745be37a2ba5911e52436 /Source/Asura.Engine/Graphics/STBDecoder.cpp
parentc19a282e10f51ddd50d198b903f8fbd5a2238b62 (diff)
*misc
Diffstat (limited to 'Source/Asura.Engine/Graphics/STBDecoder.cpp')
-rw-r--r--Source/Asura.Engine/Graphics/STBDecoder.cpp26
1 files changed, 11 insertions, 15 deletions
diff --git a/Source/Asura.Engine/Graphics/STBDecoder.cpp b/Source/Asura.Engine/Graphics/STBDecoder.cpp
index d4d578f..b14d0f3 100644
--- a/Source/Asura.Engine/Graphics/STBDecoder.cpp
+++ b/Source/Asura.Engine/Graphics/STBDecoder.cpp
@@ -8,25 +8,21 @@ namespace AsuraEngine
namespace Graphics
{
- bool STBDecoder::CanDecode(const Filesystem::DataBuffer* buffer)
+ bool STBDecoder::CanDecode(const Filesystem::DataBuffer& buffer)
{
int w = 0;
int h = 0;
int comp = 0;
- int status = stbi_info_from_memory((const stbi_uc *)buffer->data, buffer->size, &w, &h, &comp);
+ int status = stbi_info_from_memory((const stbi_uc*)buffer.data, buffer.size, &w, &h, &comp);
return status == 1 && w > 0 && h > 0;
}
- void STBDecoder::Decode(const Filesystem::DataBuffer* db, ImageData* imageData)
+ void STBDecoder::Decode(const Filesystem::DataBuffer& db, ImageData& imageData)
{
- if (!db)
- throw Exception("Could not decode image with stb decoder because of null databuffer.");
- if (!imageData)
- throw Exception("Could not decode image with stb decoder because of null output image data.");
- const stbi_uc *buffer = (const stbi_uc *)db->data;
- int bufferlen = db->size;
+ const stbi_uc *buffer = (const stbi_uc *)db.data;
+ int bufferlen = db.size;
int width, height;
int comp = 0;
byte* data = nullptr;
@@ -49,12 +45,12 @@ namespace AsuraEngine
if (data)
{
// ֤ڴ汻ͷţһϲûͷŵΪimage dataһԵģimageǶεġ
- if (imageData->pixels)
- delete[] imageData->pixels;
- imageData->pixels = (byte*)data;
- imageData->format = format;
- imageData->width = width;
- imageData->height = height;
+ if (imageData.pixels)
+ delete[] imageData.pixels;
+ imageData.pixels = (byte*)data;
+ imageData.format = format;
+ imageData.width = width;
+ imageData.height = height;
}
else
{