Notifications
Clear all
[Closed] releasing System.Drawing.Image
Aug 06, 2009 1:18 pm
I create some dynamic dotNet buttons with images in stringstream and i have problem releasing the bitmaps. My code is below, myObjects is array of structs(object id and imagefile).
ss = "" as stringstream
for o in myObjects do
(
local image = "(dotNetClass \"System.Drawing.Image\").fromFile \"" + o.imageFile + "\""
format "
Button%.Image=%
" o.ID image to:ss
)
execute (ss as string)
When i close the script, I can’t delete or modify those used bitmaps. Unless I close max :rolleyes:. I use gc light:true when dialog is destroyed.
1 Reply
Aug 06, 2009 1:18 pm
Try this. Can I ask why you are building the whole line as a string and then executing it. You should just be able to dynamically build the file path so that you don’t have to use execute.
img=(dotNetClass "System.Drawing.Image").fromFile "theFileNamePath"
img.dispose()