summaryrefslogtreecommitdiff
path: root/Source/Asura.Engine/Graphics/ImageData.h
blob: 925a5a0e4e6165c215f355a2d1103e845ea61f5c (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
#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 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;

			//----------------------------------------------------------------------------------------------------------
			
			LUAX_DECL_FACTORY(ImageData);

			LUAX_DECL_METHOD(l_GetPixel);
			LUAX_DECL_METHOD(l_GetSize);

			//----------------------------------------------------------------------------------------------------------
		
		private:

			// stbJPEGTGABMP,lodePNGpngͼƬ
			void Decode(const Filesystem::DataBuffer* buffer) override;

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

		};

	}
}

#endif