summaryrefslogtreecommitdiff
path: root/source/libs/asura-lib-core/graphics/image_data.h
blob: 820e276e708ca689323e71d1a173f433341dfe99 (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
63
64
65
66
67
68
#ifndef __ASURA_ENGINE_IMAGEDATA_H__
#define __ASURA_ENGINE_IMAGEDATA_H__

#include <list>

#include <asura-lib-utils/scripting/portable.hpp>
#include <asura-lib-utils/io/decoded_data.h>
#include <asura-lib-utils/io/data_buffer.h>
#include <asura-lib-utils/threading/thread.h>

#include "pixel_format.h"
#include "color.h"

namespace AsuraEngine
{
	namespace Graphics
	{

		class ImageDecoder;

		class ImageData ASURA_FINAL
			: public AEIO::DecodedData
			, public Scripting::Portable<ImageData>
		{
		public:

			LUAX_DECL_FACTORY(ImageData);

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

			void Load(const AEIO::DataBuffer& buffer);
			void LoadAsync(const AEIO::DataBuffer& buffer, AEThreading::Thread* thread);

			Color GetPixel(uint x, uint y);

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

		private:

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

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

			LUAX_DECL_METHOD(_New);
			LUAX_DECL_METHOD(_GetPixel);
			LUAX_DECL_METHOD(_GetSize);
			LUAX_DECL_METHOD(_GetWidth);
			LUAX_DECL_METHOD(_GetHeight);
			LUAX_DECL_METHOD(_GetPixelFormat);

		};

	}
}

namespace AEGraphics = AsuraEngine::Graphics;

#endif