Rasterize to PNG image?


#1

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?


(David Rutten) #2

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?


(David Rutten) #3

image pattern exporter.gh (18.2 KB)


#4

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


(David Rutten) #5

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?


#6

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: