How I can make .BMP file in grasshopper?

Hi everyone !
I would like to make some geometric file and save in a .BMP file there is any one have a suggestion ?
Thank you

Do you want to draw a bitmap image from scratch, or capture the Rhino viewport, or… ?

Hi David,
both of them :slight_smile:
I would like to make a script that create a .BMP …do you have any idea?

hi… thank you

I still don’t know what exactly you’re after. A viewport capture? A viewport capture with additional stuff drawn on top? An image with custom drawn elements, one of which is a viewport?

Maybe it would help if you uploaded a sketch of what you’re looking for.

You could also use animate slider in Grasshopper
image
Then

Or -viewCaptureToFile in Rhinoceros …

Hi thank you for both of you, maybe I was not so clear …

I would like to do .bmp file (like in the pics’) for a Jacquard Knitting in grasshopper . That i could to cooler geometric… and knitting them after.
:slight_smile:

Many Tnx this project is super impotent to me…

3

Okay so you’re looking for a way to specify individual pixels in an image and then save that image as a file. Grasshopper itself doesn’t allow to create images through components, but you can get a plugin via the Rhino _TestPackageManager command called imaging-library. This plugin adds some components to the Display.Image panel for drawing shapes and saving bitmaps:

However it’s not really the approach you need, as you’re not drawing shapes, you’re setting pixels. Of course you could just draw one-pixel rectangles with those tools, but there are more efficient approaches.

I’ll upload a C# script component which allows you to generate images by specifying width, height, and a list of colours per pixel.

createpixelimage.gh (10.3 KB)

The file repeats the colours you provide, so you’ll have to provide as many colours as you have pixels to make a non-repeating pattern.

image

3 Likes

And if you want to see live what David has done. Do that (not very fast on my PC. I did that on multiple mesh to have the pixelated effect. The orientation is not the same because mesh plane is not oriented as bitmap. But that could be flipped.

And if you want tileable texture, you can draw on a torus. I put an example here with a noise. The noise could be deformed with torus twist. You can select greyed image or balck and white image.


createpixelimage_LD2.gh (22.9 KB)

Hi David thank very much … it’s really helpful :black_heart:

It can be made a lot faster if performance turns out to be a problem. But for the small images you posted it probably doesn’t matter much.

Getting a strange error when I load this file now…

Looks like the culprit is image.Save(Filename);, the error goes away commenting this line.

I am running Rhino version:
Version 6 SR21
(6.21.19351.9141, 12/17/2019)

And Grasshopper Version Tuesday 17 Dec 2019 (1.0.0007).

Thanks!

Are you saving to a location that you are allowed to access?

Oh, I actually figured this out a while ago. Turns out, if the stream used to read/generate the image is closed before writing it, bad things happen.

The problem: https://stackoverflow.com/a/336396/1934487

A sample project where Bitmaps are successfully written to the system: https://github.com/garciadelcastillo/runwayml-experiments/tree/master/2020.03.18_GH-Runway-AST

1 Like