[Closed] how to reload a bitmap
I coded a tool that i can transfer pose data from one workstation to another, easily using INI files. Recently i added this new window (1) that pops up when we select a pose from the list box (2), giving a thumbnail of the pose.
my problem is, when i replace/update an existing pose, my function that overwrittes the old thumbnail image do its work properly (as you can see in (3), the old image is replaced by the new one),
but my code that loads the thumbnail, when i select an item from the pose list still loads the old thumbnail of the replaced pose.(as you can see in the (1) window)
this problem exist until i restart max.
so how can I get rid of this old thumbnail ‘cache’- (i suppose) and make my listbox click even load the new bitmap? (as you can see by the code i used in the end of the thread i even tried freeSceneBitmaps() function, but no good)
my current code :
on expression_list selected nameIndex do
(
--make text box have the slected item's name
set_textbox_to_sel_name()
looking_bitmap=openBitMap (getFilenamePath(getSourceFileName()) + "\\snapgrabs\\"+ edt1.text + ".jpg")
if looking_bitmap != undefined then (
--reads the dimentions of the current looking bitmap
looking_bitmap_w = looking_bitmap.width
looking_bitmap_h = looking_bitmap.height
createdialog thumbview looking_bitmap_w looking_bitmap_h style:#(#style_toolwindow)
thumbview.thumbnail.width= looking_bitmap_w
thumbview.thumbnail.height= looking_bitmap_h
freeSceneBitmaps()
thumbview.thumbnail.filename = (getFilenamePath(getSourceFileName()) + "\\snapgrabs\\"+ edt1.text + ".jpg")
)
else DestroyDialog thumbview
)
You don’t have to “freescenebitmaps()” to close the old bitmap.
Just make a “close yourBitmap” or “free yourBitmap”.
But all of this is not necessary.
To update the control “thumbnail” in your dialog “thumbview”, you should assign its bitmap propertie to the replaced one.
For example :
(
delete objects
try( destroyDialog rl_test )catch()
-- creation of a first bitmap to the disk for the purpose of this example
f = (getDir #scripts + "\ est.jpg")
tmpBmp = bitmap 100 80 color:black
tmpBmp.filename = f
save tmpBmp
close tmpBmp
free tmpBmp
--
-- so, load bmp from disk
img = openBitmap (getDir #scripts + "\ est.jpg")
rollout rl_test "test" (
imgTag imgt "" bitmap:img width:100 height:80
on imgt mouseDown do (
delete objects
Plane()
Teapot()
)
on imgt mouseup do (
-- replace img
newImg = gw.getViewportDib()
newImg.filename = f
save newImg -- replace
-- reload to UI
imgt.bitmap = newImg -- UI update is done
)
)--end rl
createDialog rl_test 130 110
)
it give no trouble when i use your method. but here, im trying to do the saving and loading part separately. so i will have to use ‘openBitmap’ not even for the beginning, but when i load it. the problem is, it seems to be loading the same old bitmap no matter what i try. :shrug: