algorithmic modeling for Rhino

Hi GH-maniacs!

Let's say that you want to put as accurately as possible a floating point data encoded into a BMP, PNG, or another not compressed or lossless format, and you are trying to do it with the tools provided by System.Drawing (I know, there is a module called PIL that works in Python but I couldn't get it properly working so I just jumped to System namespace...).

The first problem that I found is that there is no a direct way to store colours into saved images in other format different than 8 bits per channel...

PixelFormat48bppRGB, PixelFormat64bppARGB, and PixelFormat64bppPARGB use 16 bits per color component (channel). GDI+ version 1.0 and 1.1 can read 16-bits-per-channel images, but such images are converted to an 8-bits-per-channel format for processing, displaying, and saving. Each 16-bit color channel can hold a value in the range 0 through 2^13.

From -> here. the accuracy of the information stored is very very low (as much as 256 possible values per channel, ≈ 16M of different values per pixel) if I need to store the data in the hard-drive (thing that I would anxiously like to do for further processing).

  • So, is there any efficient way of storing at least 16bits (it's not an ideal solution could work) per channel data into an image file using System namespace instead of an external library?.

...the thing is that I know that using:

imageTest = System.Drawing.Bitmap(mX,mY,System.Drawing.Imaging.PixelFormat.Format48bppRgb)

...I can create a 16bits per channel image, but how could I specify the 16bit color if System.Drawing.Color limit the range to 8bits values?

  • And ideally, does anyone knows how to work with and save directly floating point colours into image files using python?

Thanks in advance ;)


Sevilla, Spain.

Views: 1808

Replies to This Discussion

Pffff...I found THIS and it looks that I have just entered an "interesting" maze :S

Any additional advice is welcome ;) I'll start tomorrow implementing that if I don't find any better way to write 16bit channels into an image file.

Thanks in advance.

Hi Angel

I think you found a good source of example in that project. One of the problems here is that System.Drawing.Color is 32-bit (has a fixed size) and the other is that GDI+ down-converts all images.

By searching, just like you, I found this one library that is wrapped for .Net. You could have a look at that, too.

Giulio Piacentino
for Robert McNeel & Associates

I'm not sure if this helps, but I'm using the writeable bitmap in C#:

You can specify the pixel format, which at most would give you 4 x 16 = 64 bits.

If that's not enough, then I'd think image is not the right file format anyway - you could just use a *.csv or similar.

Cheers, Thomas






  • Add Photos
  • View All


  • Add Videos
  • View All

© 2021   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service