summaryrefslogtreecommitdiff
path: root/html/examples/show_flower.wlua
diff options
context:
space:
mode:
authorscuri <scuri>2009-06-26 17:14:56 +0000
committerscuri <scuri>2009-06-26 17:14:56 +0000
commit193cd3427108bd127e09f391f7fe51f6b62590e9 (patch)
tree7dfd83dec634c15f87f578266f6fdb0df046613a /html/examples/show_flower.wlua
parent734afa90c3dda1232e9490d08346be4f2ffefec1 (diff)
*** empty log message ***
Diffstat (limited to 'html/examples/show_flower.wlua')
-rw-r--r--html/examples/show_flower.wlua31
1 files changed, 31 insertions, 0 deletions
diff --git a/html/examples/show_flower.wlua b/html/examples/show_flower.wlua
new file mode 100644
index 0000000..ec97a88
--- /dev/null
+++ b/html/examples/show_flower.wlua
@@ -0,0 +1,31 @@
+require"imlua"
+require"cdlua"
+require"cdluaim"
+require"iuplua"
+require"iupluacd"
+
+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()