From 1497dccd63a84b7ee2b229b1ad9c5c02718f2a78 Mon Sep 17 00:00:00 2001 From: chai Date: Tue, 19 Mar 2019 23:06:27 +0800 Subject: *rename --- source/libs/asura-lib-core/graphics/image.h | 76 +++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 source/libs/asura-lib-core/graphics/image.h (limited to 'source/libs/asura-lib-core/graphics/image.h') diff --git a/source/libs/asura-lib-core/graphics/image.h b/source/libs/asura-lib-core/graphics/image.h new file mode 100644 index 0000000..2dd3a4a --- /dev/null +++ b/source/libs/asura-lib-core/graphics/image.h @@ -0,0 +1,76 @@ +#ifndef __ASURA_ENGINE_IMAGE_H__ +#define __ASURA_ENGINE_IMAGE_H__ + +#include "../math/vector2.hpp" +#include "../scripting/portable.hpp" +#include "../fileSystem/reloadable.h" +#include "../stringmap.hpp" +#include "../manager.hpp" + +#include "texture.h" +#include "color.h" +#include "image_data.h" +#include "render_state.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