# How I can make .BMP file in grasshopper?

**URL:** <https://discourse.mcneel.com/t/how-i-can-make-bmp-file-in-grasshopper/74996>\
**Category:** Grasshopper\
**Created:** [November 18, 2018, 3:00pm UTC](https://discourse.mcneel.com/t/how-i-can-make-bmp-file-in-grasshopper/74996 "2018-11-18T15:00:37Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![netasoreq](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/netasoreq/32/273324_2.png) [@netasoreq](https://discourse.mcneel.com/u/netasoreq)\
**Post date:** [November 18, 2018, 3:00pm UTC](https://discourse.mcneel.com/t/how-i-can-make-bmp-file-in-grasshopper/74996/1 "2018-11-18T15:00:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![DavidRutten](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/davidrutten/32/755688_2.png) [@DavidRutten](https://discourse.mcneel.com/u/DavidRutten)\
**Post date:** [November 18, 2018, 9:33pm UTC](https://discourse.mcneel.com/t/how-i-can-make-bmp-file-in-grasshopper/74996/2 "2018-11-18T21:33:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![netasoreq](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/netasoreq/32/273324_2.png) [@netasoreq](https://discourse.mcneel.com/u/netasoreq)\
**Post date:** [November 20, 2018, 7:16am UTC](https://discourse.mcneel.com/t/how-i-can-make-bmp-file-in-grasshopper/74996/3 "2018-11-20T07:16:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![netasoreq](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/netasoreq/32/273324_2.png) [@netasoreq](https://discourse.mcneel.com/u/netasoreq)\
**Post date:** [November 25, 2018, 7:47am UTC](https://discourse.mcneel.com/t/how-i-can-make-bmp-file-in-grasshopper/74996/5 "2018-11-25T07:47:13Z")

</div>

hi… thank you

---

<div class="post-metadata">

**Author:** ![DavidRutten](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/davidrutten/32/755688_2.png) [@DavidRutten](https://discourse.mcneel.com/u/DavidRutten)\
**Post date:** [November 25, 2018, 8:29am UTC](https://discourse.mcneel.com/t/how-i-can-make-bmp-file-in-grasshopper/74996/6 "2018-11-25T08:29:59Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![laurent\_delrieu](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/laurent_delrieu/32/601605_2.png) [@laurent\_delrieu](https://discourse.mcneel.com/u/laurent_delrieu)\
**Post date:** [November 25, 2018, 2:13pm UTC](https://discourse.mcneel.com/t/how-i-can-make-bmp-file-in-grasshopper/74996/7 "2018-11-25T14:13:11Z")

</div>

You could also use animate slider in Grasshopper  
 ![image](https://global.discourse-cdn.com/mcneel/original/3X/8/6/8620aeea6ea65bfadc2f53944765521f9b7832ff.png)  
Then

 ![image](https://global.discourse-cdn.com/mcneel/original/3X/0/3/0373bcf44f2b3f6a2e495e226f73d5abdfdcc641.png)

Or -viewCaptureToFile in Rhinoceros …

---

<div class="post-metadata">

**Author:** ![netasoreq](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/netasoreq/32/273324_2.png) [@netasoreq](https://discourse.mcneel.com/u/netasoreq)\
**Post date:** [November 25, 2018, 3:12pm UTC](https://discourse.mcneel.com/t/how-i-can-make-bmp-file-in-grasshopper/74996/8 "2018-11-25T15:12:10Z")

</div>

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.  
🙂

Many Tnx this project is super impotent to me…

 ![PNG](https://global.discourse-cdn.com/mcneel/original/3X/f/f/ff6f462f535dd027a7b32eabca437c75df38eadb.jpeg) ![3](https://global.discourse-cdn.com/mcneel/original/3X/1/6/160c8aa3228b9420208f3225128dcc62d7b6612e.png) ![4](https://global.discourse-cdn.com/mcneel/original/3X/7/f/7f9ce1cc5e7acc4034bbac7641598be7337a5746.png)

---

<div class="post-metadata">

**Author:** ![DavidRutten](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/davidrutten/32/755688_2.png) [@DavidRutten](https://discourse.mcneel.com/u/DavidRutten)\
**Post date:** [November 25, 2018, 3:44pm UTC](https://discourse.mcneel.com/t/how-i-can-make-bmp-file-in-grasshopper/74996/9 "2018-11-25T15:44:13Z")

</div>

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:

 ![imagibngtools](https://global.discourse-cdn.com/mcneel/original/3X/6/1/61669faa478ae62a9a241737c6827d3e7ae7d515.png)

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.

---

<div class="post-metadata">

**Author:** ![DavidRutten](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/davidrutten/32/755688_2.png) [@DavidRutten](https://discourse.mcneel.com/u/DavidRutten)\
**Post date:** [November 25, 2018, 3:52pm UTC](https://discourse.mcneel.com/t/how-i-can-make-bmp-file-in-grasshopper/74996/10 "2018-11-25T15:52:48Z")

</div>

[createpixelimage.gh](https://global.discourse-cdn.com/mcneel/uploads/default/original/3X/b/9/b946e275a046081f44abe828b6ebb832d3bd9120.gh) (10.3 KB)

 ![pixelsetter](https://global.discourse-cdn.com/mcneel/original/3X/a/5/a5721076f9e49361aec7f9682fe25ad49550e68b.png)

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](https://global.discourse-cdn.com/mcneel/original/3X/2/7/27df75c1431646ecd33d1ac0a4dac25ec438f6d8.png)

---

<div class="post-metadata">

**Author:** ![laurent\_delrieu](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/laurent_delrieu/32/601605_2.png) [@laurent\_delrieu](https://discourse.mcneel.com/u/laurent_delrieu)\
**Post date:** [November 25, 2018, 4:53pm UTC](https://discourse.mcneel.com/t/how-i-can-make-bmp-file-in-grasshopper/74996/11 "2018-11-25T16:53:48Z")

</div>

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.

 ![image](https://global.discourse-cdn.com/mcneel/original/3X/0/7/07879b9ef269384433fef729605ad7ca7a3cb97a.png)

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.

 ![image](https://global.discourse-cdn.com/mcneel/original/3X/f/5/f58769b37b845c70e9a96f41f09c1c79e298d74e.png)  
[createpixelimage\_LD2.gh](https://global.discourse-cdn.com/mcneel/uploads/default/original/3X/c/9/c90c555f38781c49d4049f7777629fa9c6bf98b5.gh) (22.9 KB)

---

<div class="post-metadata">

**Author:** ![netasoreq](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/netasoreq/32/273324_2.png) [@netasoreq](https://discourse.mcneel.com/u/netasoreq)\
**Post date:** [November 25, 2018, 9:42pm UTC](https://discourse.mcneel.com/t/how-i-can-make-bmp-file-in-grasshopper/74996/12 "2018-11-25T21:42:19Z")

</div>

Hi David thank very much … it’s really helpful 🖤

---

<div class="post-metadata">

**Author:** ![DavidRutten](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/davidrutten/32/755688_2.png) [@DavidRutten](https://discourse.mcneel.com/u/DavidRutten)\
**Post date:** [November 25, 2018, 11:38pm UTC](https://discourse.mcneel.com/t/how-i-can-make-bmp-file-in-grasshopper/74996/13 "2018-11-25T23:38:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![garciadelcastillo](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/garciadelcastillo/32/658047_2.png) [@garciadelcastillo](https://discourse.mcneel.com/u/garciadelcastillo)\
**Post date:** [March 6, 2020, 11:51pm UTC](https://discourse.mcneel.com/t/how-i-can-make-bmp-file-in-grasshopper/74996/14 "2020-03-06T23:51:22Z")

</div>

Getting a strange error when I load this file now…

 ![JLX_2020-03-06_18-42-11_HP](https://global.discourse-cdn.com/mcneel/uploads/default/original/3X/3/0/30ab53cea4c4cd949af0787e3c156c311177abf9.png)

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!

---

<div class="post-metadata">

**Author:** ![DavidRutten](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/davidrutten/32/755688_2.png) [@DavidRutten](https://discourse.mcneel.com/u/DavidRutten)\
**Post date:** [May 24, 2020, 11:29am UTC](https://discourse.mcneel.com/t/how-i-can-make-bmp-file-in-grasshopper/74996/15 "2020-05-24T11:29:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![garciadelcastillo](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/garciadelcastillo/32/658047_2.png) [@garciadelcastillo](https://discourse.mcneel.com/u/garciadelcastillo)\
**Post date:** [May 25, 2020, 3:30pm UTC](https://discourse.mcneel.com/t/how-i-can-make-bmp-file-in-grasshopper/74996/16 "2020-05-25T15:30:37Z")

</div>

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](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](https://github.com/garciadelcastillo/runwayml-experiments/tree/master/2020.03.18_GH-Runway-AST)
