how to reload a bitmap

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Search this Thread Display Modes
  07 July 2014
Question 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
		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
				thumbview.thumbnail.filename = (getFilenamePath(getSourceFileName()) + "\\snapgrabs\\"+ edt1.text + ".jpg")
				else DestroyDialog thumbview
"A jug fills drop by drop."

  07 July 2014
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 + "\\test.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 + "\\test.jpg")
	rollout rl_test "test" (
		imgTag imgt "" bitmap:img width:100 height:80
		on imgt mouseDown do (
			delete objects
		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
  07 July 2014
thanks for the code! will try it bro!
"A jug fills drop by drop."

  07 July 2014
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.
"A jug fills drop by drop."

reply share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 08:31 PM.

Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.