summaryrefslogtreecommitdiff
path: root/Source/Asura.Engine/Graphics/ImageData.h
blob: 931eaa32fb621222b58e0b352a857903ebfb4795 (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
#ifndef __ASURA_ENGINE_IMAGEDATA_H__
#define __ASURA_ENGINE_IMAGEDATA_H__

#include <list>

#include "Scripting/Luax.hpp"
#include "Filesystem/DecodedData.h"
#include "ImageDecoder.h"
#include "PixelFormat.h"
#include "Color.h"

namespace AsuraEngine
{
	namespace Graphics
	{

		class ImageData ASURA_FINAL
			: public Filesystem::DecodedData
			, public Scripting::Portable
		{
		public:

			///
			/// ͼƬļϢʧܣ׳쳣
			///
			ImageData(const Filesystem::DataBuffer& buffer);

			~ImageData();

			Color GetPixel(uint x, uint y);

			uint width, height;
			PixelFormat format;
			std::size_t size;
			byte* pixels;

		private:

			void Decode(const Filesystem::DataBuffer& buffer) override;

			///
			/// ڵһ׼image dataʱṩdecoderڼdecodersмѡԡ
			///
			static std::list<ImageDecoder*> ImageDecoders;

		public:

			//----------------------------------------------------------------------------------------------------------

			LUAX_DECL_FACTORY(ImageData);

			LUAX_DECL_METHOD(l_GetPixel);
			LUAX_DECL_METHOD(l_GetSize);

			//----------------------------------------------------------------------------------------------------------

		};

	}
}

#endif