Use a System.Drawing.Bitmap as input?

I output a System.Drawing.Bitmap object which is the preview of an InstanceDefinition selected by the user, and I’d like to display the image in the Human UI interface.

Do I need to create an image file and reference it from it’s location ?
This is not very practical because I’ll have an awful lot of cleanup and overwrite management to do.

Is there a workaround ?

I was working on trying to preview images the other day. Not sure if this is also the case for how this works in human UI, but in order to display a bitmap (from memory) you need to create a display image out of it:

I’m super-proud of myself here :

But now, what shall I do with this stuff ?

Randomly trying …

Salut Osuire!

If you convert your image to a Base64 representation you can then use Human’s “Deserialize Image from String” and plug that result (which is a temporary file created from the B64) directly into HumanUI’s image components. That’s the most straightforward workaround I can think of off the top of my head.


Alternatively, you could just write to a temp directory directly (using the same paradigm as Andrew uses in Human) and output the temporary filepath. This can be be used directly with HumanUI’s Set Image component. (Don’t use it with Create for dynamically generated content.)

string tempPath = Path.GetTempPath();
text = Path.GetRandomFileName();
text = Path.ChangeExtension(text, ".png");
text = Path.Combine(tempPath, text);

Bonjour Marc !

Merci pour ta réponse, and thanks also for your Telepathy plugin which has transformed our messy noodle-O-ramas into readable definitions.

Here’s my progress on that front (C# idiot here) : I converted the System.Drawing.Bitmap into an array with the ImageConverter.ConvertTo method, but then, the Convert.ToBase64String method doesn’t like what I’m feeding it :

@marcsyp ?