[Closed] Converting maxscript bitmap value to dotnet image value
I need to set a dotnet image from a maxscript bitmap value, the easiest way I’ve found to do this so far is to use setclipboard and getclipboard or to write the file out and read it. I’m need to run this on a timer to update frequently and the writing to file will be too slow, and I don’t like that you effectively ‘use up’ your copy and paste functions whilst the script is running.
Is there any other way to convert this value with the same speed of the copy/paste?
With pure maxscript, no.
Two native memory copies (clipboard copy/paste) will always be faster than a file save and a file load, and much faster than moving every pixel through maxscript.
What would help is a c++ function that accepts a maxscript bitmap and returns a dotnet image.
i am dreaming of a day when the max bitmap to .net bitmap conversion (with alpha channel) will be a built-in max function. hehhh… too busy… many tools still need a new look.
I requested this method for the dotnet SDK in the 2012 beta cycle. Until this is addressed, get/set clipboard method remains the best we have.
What would help is a c++ function that accepts a maxscript bitmap and returns a dotnet image.
I don’t think it’s possible that way round as mxs function publishing doesn’t have the return type for dotnet image. (unless any one knows better). Don’t really know much dotnet, can you extend the image class to take a mxs bitmap as a constructor argument and link to the sdk libs ?
one possibility is c++ function mxs bitmap to intptr then maybe…
dotnet_bm = dotnetobject "System.Drawing.Bitmap" w h stride pformat (BitmapToIntArray mxs_bm)
might work, it might be neater possibly quicker than the copy/paste method but still requires 2 * w * h memory shifts, one in the function to construct the out pixel array and one in the dotnet bitmap constructor.
don’t think it can be done as above, as far as I can work out mxs has no concept of pointers or int/char/byte arrays only of arrays of int objects or “tables” of ints.