summaryrefslogtreecommitdiff
path: root/Source/modules/asura-core/Image/ImageData.h
diff options
context:
space:
mode:
Diffstat (limited to 'Source/modules/asura-core/Image/ImageData.h')
-rw-r--r--Source/modules/asura-core/Image/ImageData.h81
1 files changed, 81 insertions, 0 deletions
diff --git a/Source/modules/asura-core/Image/ImageData.h b/Source/modules/asura-core/Image/ImageData.h
new file mode 100644
index 0000000..2d70edc
--- /dev/null
+++ b/Source/modules/asura-core/Image/ImageData.h
@@ -0,0 +1,81 @@
+#ifndef _ASURA_ENGINE_IMAGEDATA_H_
+#define _ASURA_ENGINE_IMAGEDATA_H_
+
+#include <list>
+
+#include <asura-base/Scripting/Scripting.h>
+#include <asura-base/FileSystem/DecodedData.h>
+#include <asura-base/FileSystem/DataBuffer.h>
+#include <asura-base/Threads/Thread.h>
+#include <asura-base/Threads/Mutex.h>
+
+#include "../Graphics/Texture.h"
+#include "../Graphics/Color.h"
+
+namespace_begin(AsuraEngine)
+namespace_begin(Image)
+
+class ImageDecoder;
+
+class ImageData ASURA_FINAL
+ : public Scripting::Portable<ImageData>
+ , public AEFileSystem::DecodedData
+{
+public:
+
+ ///
+ /// ͼƬļϢʧܣ׳쳣
+ ///
+ ImageData();
+ ~ImageData();
+
+ void Decode(AEFileSystem::DataBuffer& buffer) override;
+
+ void Lock();
+ void Unlock();
+
+ AEGraphics::Color GetPixel(uint x, uint y);
+
+ //----------------------------------------------------------------------------//
+
+ uint width, height; // سߴ
+ AEGraphics::ColorFormat format; // ʽ
+ byte* pixels; //
+ std::size_t size; // ݳ
+
+ //----------------------------------------------------------------------------//
+
+private:
+
+ ///
+ /// ڵһ׼image dataʱṩdecoderڼdecodersмѡԡ
+ ///
+ static std::list<ImageDecoder*> ImageDecoders;
+
+ ///
+ /// дݵ
+ ///
+ AEThreading::Mutex m_Mutex;
+
+luaxport:
+
+ LUAX_DECL_FACTORY(ImageData);
+
+ LUAX_DECL_METHOD(_New);
+ LUAX_DECL_METHOD(_GetPixel);
+ LUAX_DECL_METHOD(_GetSize);
+ LUAX_DECL_METHOD(_GetWidth);
+ LUAX_DECL_METHOD(_GetHeight);
+ LUAX_DECL_METHOD(_GetPixelFormat);
+ LUAX_DECL_METHOD(_Decode);
+ LUAX_DECL_METHOD(_DecodeAsync);
+ LUAX_DECL_METHOD(_IsAvailable);
+
+};
+
+namespace_end
+namespace_end
+
+namespace AEImage = AsuraEngine::Image;
+
+#endif \ No newline at end of file