View Full Version : Using Base64 encoded strings - New Article on LoneRobot.com
12-17-2008, 10:17 AM
Just a note to say I've posted a new article about Base64 encoding in 3dsMax on my site. It's part of my research to find ways of deploying scripts without the need for image files or dependancies. Included is a small utility that can convert your images into strings to use, and a function for converting them back. Click the image to read it!
12-17-2008, 11:34 AM
Handy. And with your usual knack for presentation! :)
12-17-2008, 12:02 PM
Awesome :) I used to convert bitmap pixels to rgb string arrays and them converting it back, but using base64 itīs really nice and fast.
Congratulations and thanks a lot for sharing :)
12-17-2008, 12:21 PM
Thanks Fabio, Dr, you are welcome!
This is great, and just what I needed...umm, what can I use this for:S
12-17-2008, 01:18 PM
a... fully portable script file that doesn't leave data on the host machine (to limited extent)? Maybe.. most of what you might use this for is something that you'd typically do with a .MZP . It's fun to play with, regardless :)
12-17-2008, 05:51 PM
Great idea! :thumbsup:
p.s. When I'll tried download file it is not found, can it be fixed?
12-17-2008, 06:36 PM
My apologies, It is fixed now.
05-26-2009, 02:08 PM
I was trying yous base64 script but ran into an error:
>> MAXScript Rollout Handler Exception: -- Runtime error: dotNet runtime exception: Cannot widen from source type to target type either because the source type is a not a primitive type or the conversion cannot be accomplished. <<
It's in the line memstream = dotnetobject "System.IO.MemoryStream" bytearr of the function which converts string to image.
Also when I try just the function to convert an image into a string it doesn't work. Maybe i'm missing some loadassembly at the top, but I wouldn't know which. Could you help me get it to work?
I'm on a 64 bit machine btw.
05-26-2009, 02:50 PM
hi klaas, i've tried the script on a 64bit computer and it seems to work okay. Have you downloaded the utility from the article and tried it? - the code example is just a portion and doesn't contain the imageclass declaration. if the rollout runs, it is working as the lonerobot logo on the corner is loaded from a base64 string!
05-26-2009, 03:42 PM
Thanks Pete for helping,
yes, I've downloaded the script at the end of the article. The line in my post is the line where the error occurs. The rollout builds nicely, but no image is created (your robot-logo should appear right?). Also my home pc (vista 32 bit) and a similar pc here at work produce the same error.
Could it be related to .NET versions maybe? Or some kind of assembly you naturally have loaded since you develop this stuff.
05-26-2009, 04:42 PM
there aren't any custom assemblies being loaded by this script, so im not sure why it is saying this. which version of max are you running?
is the convertclass returning a bytearray from the base64 string? it is possible, if it is pre max 2008 that it is not returning the dotnetarrays into the correct format.
try this minimal code version, line by line and see if it fails at the same place -
05-26-2009, 04:55 PM
I've tried the script line by line. It fails at the line memstream = dotnetobject "System.IO.MemoryStream" bytearrWith the same error in the previous post. This is in max 2008 32 and 64 bit edition. Max 2010, 32 and 64 work fine.
I actually wasn't thinking about custom assemblies (like those snazzy controls you make) but the plain asseblies you sometimes have to load to make things work. Like the "system.xml" one. And if I try dotNet.loadAssembly "System.IO"I get an undefined in the listener. That can't be good, right?
05-26-2009, 09:36 PM
After testing, It's a max 2008 issue i'm afraid, im having the same issue as you in max2008. Max is not casting the byte array into dotnet (perhaps something to do with the fact max casts bytes to integers) and was a known bug of this release.
it was a while since i wrote that article but i must have written in after upgrading to max 2009. My GDI research tried to get around this by populating a byte array from a max array, but that is also returning the error you mentioned. So sorry, it's kind of out of my hands in that version of max except to say i can emcompass the method into a dotnet assembly for you. One advantage to counter the need to load a custom assembly would be that it would be much faster this way. Let me know if you wanted this option and i'll compile something for you to use in max 2008.
05-26-2009, 09:51 PM
that's a pity it doesn't work, but great to have it figured out. Since our company is migrating to max 2010 anyway, we don't really have the need for your kind offer. And as far as my own public scripts go: either distributing two icon-files, or a dotnet assembly doesn't really make a difference (logistics wise). So thanks very much for the help, but don't bother to make that assembly just for me.
05-26-2009, 10:38 PM
no problem klaas.
05-26-2009, 10:38 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.
vBulletin v3.0.5, Copyright ©2000-2014, Jelsoft Enterprises Ltd.