summaryrefslogtreecommitdiff
path: root/Source/modules/asura-framework/scripts/graphics/image.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Source/modules/asura-framework/scripts/graphics/image.lua')
-rw-r--r--Source/modules/asura-framework/scripts/graphics/image.lua40
1 files changed, 40 insertions, 0 deletions
diff --git a/Source/modules/asura-framework/scripts/graphics/image.lua b/Source/modules/asura-framework/scripts/graphics/image.lua
new file mode 100644
index 0000000..f5ebaa2
--- /dev/null
+++ b/Source/modules/asura-framework/scripts/graphics/image.lua
@@ -0,0 +1,40 @@
+-- 图片资源
+AsuraEngine.Image = AsuraEngine.Asset.Extend("Image")
+
+local Image = AsuraEngine.Image
+
+function Image.Ctor(self, path)
+ local simImage = AsuraEngine.SimImage.New(path)
+ local w, h = simImage:GetSize()
+ self.simImage = simImage
+ self.width = w
+ self.height = h
+end
+
+function Image.GetWidth(self)
+ return self.simImage.GetWidth()
+end
+
+function Image.GetHeight(self)
+ return self.simImage.GetHeight()
+end
+
+function Image.GetSize(self)
+ return self.simImage.GetSize()
+end
+
+--获得x,y位置的颜色值
+function Image.GetColor(self, x, y)
+ return self.simImage.GetColor(x, y)
+end
+
+--获得所有像素,返回到一个table里
+function Image.GetPixels(self)
+ return self.simImage:GetPixels()
+end
+
+--image不可再编辑器编辑,所以没有ToAsset方法
+--function Image.ToAsset()
+--end
+
+return Image \ No newline at end of file