diff options
author | chai <chaifix@163.com> | 2019-01-19 01:44:05 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-01-19 01:44:05 +0800 |
commit | 91e589d1678a8187c307e09b98b67ec4133092ff (patch) | |
tree | ee2761f047568ca7164b27399c0b2fb2f21c26b0 /Source/Asura.Engine/Graphics/Image.h | |
parent | 91346d709abb37a063d0c29ddeb2d1a849d3afc2 (diff) |
*游戏框架改用脚本实现
Diffstat (limited to 'Source/Asura.Engine/Graphics/Image.h')
-rw-r--r-- | Source/Asura.Engine/Graphics/Image.h | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/Source/Asura.Engine/Graphics/Image.h b/Source/Asura.Engine/Graphics/Image.h new file mode 100644 index 0000000..5b27079 --- /dev/null +++ b/Source/Asura.Engine/Graphics/Image.h @@ -0,0 +1,119 @@ +#ifndef __AE_IMAGE_H__ +#define __AE_IMAGE_H__ + +#include "Math/Vector2.h" +#include "Manager.hpp" +#include "Texture.h" +#include "Color.h" +#include "Factory.h" + +namespace AsuraEngine +{ + namespace Graphics + { + + class ImageFactory; + + /// + /// ImageͼƬڴȡϷĽһImageڴ桢ԴֻᱣһݣҪ + /// imageêλãźתǶȣʹspriteһֻࡣ + /// + class Image final : public Texture, public Filesystem::Asset + { + public: + + uint GetWidth(); + uint GetHeight(); + + /// + /// ijһλõ + /// + Color GetPixel(uint x, uint y); + + private: + + friend class ImageFactory; + + Image(Color* pixels, int width, int height); + ~Image(); + + /// + /// СΪλ + /// + uint mWidth, mHeight; + Color* mPixels; + + /// + /// ID + /// + uint mID; + + }; + + /// + /// + /// + class ImageManager : public Manager + { + public: + + /// + /// ͨIDȡ·dzͼƬString::Null + /// + Containers::String GetImagePath(uint ID); + + /// + /// ͨID·ȡIDûҵ0 + /// + uint GetImageID(const Containers::String& path); + + Image* GetImage(const Containers::String& path); + + Image* GetImage(const Containers::String& ID); + + uint AddImage(const Containers::String& path, Image* image); + + uint AddImage(Image* image); + + bool RemoveImage(uint ID); + + bool RemoveImage(Image* image); + + private: + + /// + /// еimage + /// + Containers::Map<uint, Image*> mImages; + + /// + /// image·IDӳ䡣Դ.asrimageͨ·õimageԲеimageڴmapС + /// ɳimageֻͨIDȡԳҪID + /// + Containers::StringMap<uint> mImageIDs; + + }; + + /// + /// + /// + class ImageFactory : public Factory + { + public: + + /// + /// image pixelйimage + /// + Image* ReadBuffer(Color* pixels, int width, int height); + + /// + /// image externݲ + /// + Image* Decode(); + + }; + + } +} + +#endif
\ No newline at end of file |