summaryrefslogtreecommitdiff
path: root/source/modules/asura-core/Image/ImageData.cpp
blob: c75166f924cddb4268ff894f0cfbdb30a9398764 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "ImageData.h"
#include "PngDecoder.h"
#include "StbDecoder.h"
#include "ImageDecoder.h"

using namespace std;

using namespace AEGraphics;

namespace_begin(AsuraEngine)
namespace_begin(Image)

// imagedecoderΪԡ
list<ImageDecoder*> ImageData::ImageDecoders = {
	new PNGDecoder(), // png 
	new STBDecoder()  // jpeg, tga, bmp
};

ImageData::ImageData()
	: pixels(nullptr)
	, size(0)
	, width(0)
	, height(0)
	, format(COLOR_FORMAT_UNKNOWN)
{
}

ImageData::~ImageData()
{
	if (pixels)
		delete[] pixels;
}

void ImageData::Decode(IO::DataBuffer& buffer)
{
	for (ImageDecoder* decoder : ImageDecoders)
	{
		if (decoder->CanDecode(buffer))
		{
			decoder->Decode(buffer, *this);
			return;
		}
	}
}

Color ImageData::GetPixel(uint x, uint y)
{
	return Color();
}

void ImageData::Lock()
{
	m_Mutex.Lock();
}

void ImageData::Unlock()
{
	m_Mutex.Unlock();
}
		
namespace_end
namespace_end