summaryrefslogtreecommitdiff
path: root/test/lua/show_flower.wlua
diff options
context:
space:
mode:
authorscuri <scuri>2008-10-17 06:10:15 +0000
committerscuri <scuri>2008-10-17 06:10:15 +0000
commit5a422aba704c375a307a902bafe658342e209906 (patch)
tree5005011e086bb863d8fb587ad3319bbec59b2447 /test/lua/show_flower.wlua
First commit - moving from LuaForge to SourceForge
Diffstat (limited to 'test/lua/show_flower.wlua')
-rw-r--r--test/lua/show_flower.wlua31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/lua/show_flower.wlua b/test/lua/show_flower.wlua
new file mode 100644
index 0000000..a3803d7
--- /dev/null
+++ b/test/lua/show_flower.wlua
@@ -0,0 +1,31 @@
+require"imlua"
+require"iuplua"
+require"cdlua"
+require"cdluaiup"
+require"imlua_cd"
+
+image = im.FileImageLoad("flower.jpg") -- directly load the image at index 0. it will open and close the file
+cnv = iup.canvas{rastersize = image:Width().."x"..image:Height(), border = "NO"}
+cnv.image = image -- store the new image in the IUP canvas as an attribute
+
+function cnv:map_cb() -- the CD canvas can only be created when the IUP canvas is mapped
+ self.canvas = cd.CreateCanvas(cd.IUP, self)
+end
+
+function cnv:action() -- called everytime the IUP canvas needs to be repainted
+ self.canvas:Activate()
+ self.canvas:Clear()
+ self.image:cdCanvasPutImageRect(self.canvas, 0, 0, 0, 0, 0, 0, 0, 0) -- use default values
+end
+
+dlg = iup.dialog{cnv}
+
+function dlg:close_cb()
+ cnv.image:Destroy()
+ cnv.canvas:Kill()
+ self:destroy()
+ return iup.IGNORE -- because we destroy the dialog
+end
+
+dlg:show()
+iup.MainLoop()