Rasterize to PNG image?

I would like to convert 2D geometry, e.g. a pattern, to B/W (1 bit) PNG, right from Grasshopper.

Is there any way to do that, perhaps with a plugin?

I’m not sure saving specific bit-depths is do-able, but you can certainly draw some basic shapes onto a bitmap in memory and save it as BMP, JPG, or PNG using some C# code. Is your pattern geometry already aligned on the world XY plane in ‘pixel space’? Are you looking to draw edges, or fill regions?

1 Like

image pattern exporter.gh (18.2 KB)

1 Like

Thanks for the script! Only it doesn’t work in WIP: A generic error occured in GDI+. (line: 0)

My favourite type of error… I wrote it on the WIP, so that in itself is not the problem.
Did you change the file path to a location that actually exists on your computer?

1 Like

Now I did, and the error goes away! Only I had to create (touch) an empty initial file, or else I could not select it in the file selection dialog. But that’s not an issue.

This is very cool, especially as the PNG updates in real-time!

From your script, unchanged:

Does anyone know how to tweak this code so you can set the colour of the regions and have a transparent background?