Notifications
Clear all

[Closed] n00b question: bitmaps in encrypted max scripts

Hello all!

Im workin on a script which has some rollouts etc…
now in the place of author (ive created a seperate rollout for it) ive added an image. -ok- everything went fine… i defined the path to that image file etc…

heres is the method i used for adding a bitmap

rollout test “bhan*** test hai”
(
bitmap the_bmp fileName:“C:\Documents and Settings\VarinderS\My Documents\My Pictures\author.png”
)
createdialog test width:230 height:110

but when i encrypted the whole script and used it on another computer… the image didnt showed up… how may i fix it?

any help would be highly appreciated!

11 Replies

considering you used it on another computer… are you sure that…


"C:\Documents and Settings\VarinderS\My Documents\My Pictures\author.png"

…actually exists on that computer?

you may also want to use either…


"C:\\Documents and Settings\\VarinderS\\My Documents\\My Pictures\\author.png"

…or (newer max versions)…


@"C:\Documents and Settings\VarinderS\My Documents\My Pictures\author.png"

…to prevent any problems with escaped characters.

1 Reply
(@varinderll)
Joined: 11 months ago

Posts: 0

first of ll thannx for the replie

well no… that is the problem i dont want to create a directory on other computer…
isnt there any other way around for adding bitmaps into your encrypted scripts without specifying a path… jus like this person did…
http://scriptspot.com/3ds-max/max-retopo

help pls.

–sorry for my bad english

there’s two ways…

A. Use an MZP, extract all the files to a temporary location (e.g. system temp)
B. Encode your bitmap as script itself. See the Bitmap Values topic in the help file, at the very bottom is an example script that will load a bitmap file and output script code that you can then include in your main script.

this method suits me.
as explained in the help… i was able to make a function for my image.

but when i put that function into my script and execute it, no image pops up, instead listener says…

“Rollout:test
BitMap:
true”

i executed it in this way


   rollout test "bhan*** test hai"
   (
   	fn load_bitmap_author = (
   ... blah blah blah...)
   return bitmap_author
   )
 	   
   )
 load_bitmap_author()
   createdialog test width:230 height:110
   

please help

A. place the function outside of the rollout so that when you call it outside of the rollout, it’s in the same scope.

B. Call the function from within the rollout.

C. Integrate the function into e.g. the ‘on <rollout> open’ event.

ok placed it outside the rollout like this

fn load_bitmap_author = (blah.. blah...)
   rollout test "bhan*** test hai"
   (
   	   
   )
   load_bitmap_author()
   createdialog test width:230 height:110
   

on execution i still cant see the image.
the listener says something like this,
“load_bitmap_author()
Rollout:test
BitMap:
true”

could you please explain this step.

alright, suppose this is the function you got from the bitmap -> script function from the help file… (simple noise map rendered out at 8×8)


   ----------
   fn load_bitmap_test = (
   local bitmap_test=bitmap 8 8
   fn unpack val = for p in val collect (r=p/256^2; g=p/256-r*256; b=mod p 256; color r g b)
   setpixels bitmap_test [0,0] (unpack #(8092539, 8158332, 8026746, 7895160, 7829367, 7895160, 8092539, 8487297))
   setpixels bitmap_test [0,1] (unpack #(7697781, 7829367, 7895160, 7960953, 8092539, 8355711, 8750469, 9276813))
   setpixels bitmap_test [0,2] (unpack #(7631988, 7763574, 7895160, 8026746, 8289918, 8618883, 9145227, 9737364))
   setpixels bitmap_test [0,3] (unpack #(7829367, 7960953, 8026746, 8158332, 8355711, 8750469, 9276813, 9934743))
   setpixels bitmap_test [0,4] (unpack #(8158332, 8289918, 8224125, 8158332, 8289918, 8553090, 9013641, 9737364))
   setpixels bitmap_test [0,5] (unpack #(8553090, 8553090, 8355711, 8158332, 8026746, 8158332, 8553090, 9211020))
   setpixels bitmap_test [0,6] (unpack #(8816262, 8684676, 8355711, 7960953, 7697781, 7631988, 7960953, 8553090))
   setpixels bitmap_test [0,7] (unpack #(8684676, 8553090, 8158332, 7631988, 7237230, 7171437, 7434609, 8026746))
   return bitmap_test
   )
   ----------
   

Then…

A. Function inside rollout (scope is in the rollout), called from inside rollout


   (
   rollout roll_test "test" (
   	bitmap bmp_test width:10 height:10
   
   	----------
   	fn load_bitmap_test = (
   	local bitmap_test=bitmap 8 8
   	fn unpack val = for p in val collect (r=p/256^2; g=p/256-r*256; b=mod p 256; color r g b)
   	setpixels bitmap_test [0,0] (unpack #(8092539, 8158332, 8026746, 7895160, 7829367, 7895160, 8092539, 8487297))
   	setpixels bitmap_test [0,1] (unpack #(7697781, 7829367, 7895160, 7960953, 8092539, 8355711, 8750469, 9276813))
   	setpixels bitmap_test [0,2] (unpack #(7631988, 7763574, 7895160, 8026746, 8289918, 8618883, 9145227, 9737364))
   	setpixels bitmap_test [0,3] (unpack #(7829367, 7960953, 8026746, 8158332, 8355711, 8750469, 9276813, 9934743))
   	setpixels bitmap_test [0,4] (unpack #(8158332, 8289918, 8224125, 8158332, 8289918, 8553090, 9013641, 9737364))
   	setpixels bitmap_test [0,5] (unpack #(8553090, 8553090, 8355711, 8158332, 8026746, 8158332, 8553090, 9211020))
   	setpixels bitmap_test [0,6] (unpack #(8816262, 8684676, 8355711, 7960953, 7697781, 7631988, 7960953, 8553090))
   	setpixels bitmap_test [0,7] (unpack #(8684676, 8553090, 8158332, 7631988, 7237230, 7171437, 7434609, 8026746))
   	return bitmap_test
   	)
   	----------
   	
   	on roll_test open do (
   		bmp_test.bitmap = load_bitmap_test()
   	)
   )
   createDialog roll_test
   )
   

B. Function outside rollout (scope is outside the rollout, in this case a global scope), called from inside rollout


   (
   ----------
   fn load_bitmap_test = (
   local bitmap_test=bitmap 8 8
   fn unpack val = for p in val collect (r=p/256^2; g=p/256-r*256; b=mod p 256; color r g b)
   setpixels bitmap_test [0,0] (unpack #(8092539, 8158332, 8026746, 7895160, 7829367, 7895160, 8092539, 8487297))
   setpixels bitmap_test [0,1] (unpack #(7697781, 7829367, 7895160, 7960953, 8092539, 8355711, 8750469, 9276813))
   setpixels bitmap_test [0,2] (unpack #(7631988, 7763574, 7895160, 8026746, 8289918, 8618883, 9145227, 9737364))
   setpixels bitmap_test [0,3] (unpack #(7829367, 7960953, 8026746, 8158332, 8355711, 8750469, 9276813, 9934743))
   setpixels bitmap_test [0,4] (unpack #(8158332, 8289918, 8224125, 8158332, 8289918, 8553090, 9013641, 9737364))
   setpixels bitmap_test [0,5] (unpack #(8553090, 8553090, 8355711, 8158332, 8026746, 8158332, 8553090, 9211020))
   setpixels bitmap_test [0,6] (unpack #(8816262, 8684676, 8355711, 7960953, 7697781, 7631988, 7960953, 8553090))
   setpixels bitmap_test [0,7] (unpack #(8684676, 8553090, 8158332, 7631988, 7237230, 7171437, 7434609, 8026746))
   return bitmap_test
   )
   ----------
   
   rollout roll_test "test" (
   	bitmap bmp_test width:10 height:10
   	
   	on roll_test open do (
   		bmp_test.bitmap = load_bitmap_test()
   	)
   )
   createDialog roll_test
   )
   

C. Function inside rollout (scope is inside the rollout), called from outside the rollout by referencing it as part of the rollout


   (
   rollout roll_test "test" (
   	bitmap bmp_test width:10 height:10
   
   	----------
   	fn load_bitmap_test = (
   	local bitmap_test=bitmap 8 8
   	fn unpack val = for p in val collect (r=p/256^2; g=p/256-r*256; b=mod p 256; color r g b)
   	setpixels bitmap_test [0,0] (unpack #(8092539, 8158332, 8026746, 7895160, 7829367, 7895160, 8092539, 8487297))
   	setpixels bitmap_test [0,1] (unpack #(7697781, 7829367, 7895160, 7960953, 8092539, 8355711, 8750469, 9276813))
   	setpixels bitmap_test [0,2] (unpack #(7631988, 7763574, 7895160, 8026746, 8289918, 8618883, 9145227, 9737364))
   	setpixels bitmap_test [0,3] (unpack #(7829367, 7960953, 8026746, 8158332, 8355711, 8750469, 9276813, 9934743))
   	setpixels bitmap_test [0,4] (unpack #(8158332, 8289918, 8224125, 8158332, 8289918, 8553090, 9013641, 9737364))
   	setpixels bitmap_test [0,5] (unpack #(8553090, 8553090, 8355711, 8158332, 8026746, 8158332, 8553090, 9211020))
   	setpixels bitmap_test [0,6] (unpack #(8816262, 8684676, 8355711, 7960953, 7697781, 7631988, 7960953, 8553090))
   	setpixels bitmap_test [0,7] (unpack #(8684676, 8553090, 8158332, 7631988, 7237230, 7171437, 7434609, 8026746))
   	return bitmap_test
   	)
   	----------
   )
   createDialog roll_test
   roll_test.bmp_test.bitmap = roll_test.load_bitmap_test()
   )
   

D. Function integrated into the rollout opening event (scope inside rollout opening event, can’t be called externally as it is no longer a separate function).


   (
   rollout roll_test "test" (
   	bitmap bmp_test width:10 height:10
   
   	on roll_test open do (
   	----------
   	local bitmap_test=bitmap 8 8
   	fn unpack val = for p in val collect (r=p/256^2; g=p/256-r*256; b=mod p 256; color r g b)
   	setpixels bitmap_test [0,0] (unpack #(8092539, 8158332, 8026746, 7895160, 7829367, 7895160, 8092539, 8487297))
   	setpixels bitmap_test [0,1] (unpack #(7697781, 7829367, 7895160, 7960953, 8092539, 8355711, 8750469, 9276813))
   	setpixels bitmap_test [0,2] (unpack #(7631988, 7763574, 7895160, 8026746, 8289918, 8618883, 9145227, 9737364))
   	setpixels bitmap_test [0,3] (unpack #(7829367, 7960953, 8026746, 8158332, 8355711, 8750469, 9276813, 9934743))
   	setpixels bitmap_test [0,4] (unpack #(8158332, 8289918, 8224125, 8158332, 8289918, 8553090, 9013641, 9737364))
   	setpixels bitmap_test [0,5] (unpack #(8553090, 8553090, 8355711, 8158332, 8026746, 8158332, 8553090, 9211020))
   	setpixels bitmap_test [0,6] (unpack #(8816262, 8684676, 8355711, 7960953, 7697781, 7631988, 7960953, 8553090))
   	setpixels bitmap_test [0,7] (unpack #(8684676, 8553090, 8158332, 7631988, 7237230, 7171437, 7434609, 8026746))
   	----------
   	bmp_test.bitmap = bitmap_test
   	)
   )
   createDialog roll_test
   )
   

worked perfect!

thanks alot for your help

Incidentaly, you can also perform this with dotnet if you wanted to store a dotnet bitmap, by using a Base64 encoded string – I wrote a tutorial about it a while back – See here

wOw very usefull info… thanx alot LoneRobot

i have a doubt… can we use custom windows fonts in maxScript with this dotNet stuff.

Page 1 / 2