PDA

View Full Version : n00b question: bitmaps in encrypted max scripts


Varinderll
05-08-2009, 06:00 AM
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! http://www.cgempire.com/images/EmpireOrange/smilies/wink.gif

ZeBoxx2
05-08-2009, 07:52 AM
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.

Varinderll
05-08-2009, 03:42 PM
first of ll thannx for the replie :)

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?


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 :)

ZeBoxx2
05-08-2009, 04:00 PM
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.

Varinderll
05-09-2009, 12:49 AM
there's two ways...
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 :(

ZeBoxx2
05-09-2009, 07:00 AM
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.

Varinderll
05-09-2009, 08:09 AM
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"



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

could you please explain this step. :)

ZeBoxx2
05-09-2009, 09:40 AM
alright, suppose this is the function you got from the bitmap -> script function from the help file.. (simple noise map rendered out at 8x8)

----------
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
)

Varinderll
05-09-2009, 10:01 AM
worked perfect!

thanks alot for your help :D

LoneRobot
05-09-2009, 01:06 PM
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 (http://www.lonerobot.com/base64.html)

Varinderll
05-11-2009, 03:33 PM
wOw very usefull info... thanx alot LoneRobot :D

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

ZeBoxx2
05-11-2009, 06:03 PM
sure

rollout roll_test "test" width:416 height:66 (
dotNetControl dno_label "Windows.Forms.Label" width:400 height:50

on roll_test open do (
dno_label.text = "Hello World"
dno_label.font = dotNetObject "System.Drawing.Font" "Arial" 24
dno_label.foreColor = (dotNetClass "System.Drawing.Color").red
)
)
createDialog roll_test

CGTalk Moderation
05-11-2009, 06:03 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.