From 8644e03586ac9c39741f62cbcbce87b18805538c Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 14 Mar 2019 23:12:54 +0800 Subject: =?UTF-8?q?*=E5=A4=A7=E5=B0=8F=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/Asura.Engine/graphics/image.h | 78 ++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 Source/Asura.Engine/graphics/image.h (limited to 'Source/Asura.Engine/graphics/image.h') diff --git a/Source/Asura.Engine/graphics/image.h b/Source/Asura.Engine/graphics/image.h new file mode 100644 index 0000000..66c7ae1 --- /dev/null +++ b/Source/Asura.Engine/graphics/image.h @@ -0,0 +1,78 @@ +#ifndef __ASURA_ENGINE_IMAGE_H__ +#define __ASURA_ENGINE_IMAGE_H__ + +#include "Math/Vector2.hpp" +#include "Scripting/Portable.h" +#include "FileSystem/Reloadable.h" +#include "StringMap.hpp" +#include "Manager.hpp" +#include "Texture.h" +#include "Color.h" +#include "ImageData.h" + +namespace AsuraEngine +{ + namespace Graphics + { + + class ImageFactory; + + /// + /// Image是图片从内存中载入后,读取进游戏后保存的结果。一个Image在内存、显存中只会保存一份,不会产生副本。需要特征 + /// 化的区别image,如锚点位置,缩放和旋转角度,使用sprite。是一个只读类。主要是考虑到editor和engine使用不同的封装。 + /// + class Image ASURA_FINAL + : public Drawable + , public Scripting::Portable + , public Filesystem::Reloadable + { + public: + + Image(); + + ~Image(); + + /// + /// 从数据buffer构建image像素信息,如果mPixels不为空,先清空数据。用来重新构建image,使用glTexImage2D重新提交image + /// 的像素数据。 + /// + bool Load(ImageData* data); + + uint GetWidth(); + uint GetHeight(); + Math::Vector2u GetSize(); + + /// + /// 获得某一个位置的像素 + /// + Color32 GetPixel(uint x, uint y); + + void Render(const RenderTarget* rt, const RenderState& state) override; + + void Render(const RenderTarget* rt, const Math::Rectf& quad, const RenderState& state) override; + + private: + + ImageData* mImageData; + + Math::Vector2u mSize; + + public: + + //---------------------------------------------------------------------------------------------------------- + + LUAX_DECL_FACTORY(SimImage); + + LUAX_DECL_METHOD(l_Load); + LUAX_DECL_METHOD(l_GetWidth); + LUAX_DECL_METHOD(l_GetHeight); + LUAX_DECL_METHOD(l_GetSize); + + //---------------------------------------------------------------------------------------------------------- + + }; + + } +} + +#endif \ No newline at end of file -- cgit v1.1-26-g67d0