[Iup-users] How to display an image ?

Adriano Roberto de Lima limaadriano at gmail.com
Sun Dec 23 18:09:48 GMT+3 2007


Hi.
 
I am using the code below to try to show an image using iup/lua/cd/im.
Eveything seems ok, but when I execute the code (using iuplua5.1.exe -
iuplua console) I receive the following error message: "[string "local
file_name = "lena.jpg"..."]:13: attempt to call method 'cdPutImageRect' (a
nil value)"
 
What is wrong ? Could you help me ?
 
Thanks a lot
Adriano
 
--- CODE ---
 
local file_name = "lena.jpg" -- the image exists
local image = im.FileImageLoad(file_name) --directly load the image at index
0. it will open and close the file
local cv = iup.canvas{rastersize = image:Width().."x"..image:Height(),
border = "NO"}
cv.im_image = image
 
function cv:map_cb()       -- the CD canvas can only be created when the IUP
canvas is mapped
   self.cd_canvas = cd.CreateCanvas(cd.IUP, self)
end
 
function cv:action()          -- called everytime the IUP canvas needs to be
repainted
   cd.Activate(self.cd_canvas)
   cd.Clear()
   self.im_image:cdPutImageRect(0, 0, 0, 0, 0, 0, 0, 0)
end
 
dlg = iup.dialog{cv}
 
function dlg:close_cb()      -- just an example
   local cv = dlg[1]
   im.ImageDestroy(cv.im_image)
   cd.KillCanvas(cv.cd_canvas)
   dlg:destroy()
   return iup.IGNORE -- because we destroy the dialog
end
 
dlg:show()
 
--- END OF THE CODE


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.luaforge.net/pipermail/iup-users/attachments/20071223/c0d94ca8/attachment.html


More information about the iup-users mailing list