algorithmic modeling for Rhino

I'm writing a C# script in Grasshopper to perform image averaging.  The goal is to analyze the color gradient of an architectural plan and apply transformations (TBD) to produce different effects.

Although Grasshopper has an image sampler component, I wanted to code one myself but am facing difficulties in assigning a Type Hint to the C# input - there is no Image option. Does anyone have suggestions? Thanks!

Views: 978

Replies to This Discussion

given the conversation above, it might be time to get rid of the "var" to protect myself;)

var are type placeholders in C# and therefore i didn't know that a got a return image instead. Also I didn't instantiate so "new" might also be the problem.

As always, tnx

I think the problem here is one of inheritance. Image is the more generic type, while Bitmap derives from Image. Images can be WMF and EMF files as well, and those are vector based formats. Bitmaps deal strictly with pixels.

The FromFile method is actually defined on Image, not Bitmap, and as such it returns an Image type. Since an Image doesn't know anything about pixels, it doesn't provide the GetPixel/SetPixel functionality.

Yes, that was the case. I got it to work with bitmap type. I still find it weird that the image type doesn't have a way to access the data (raw or not). I could be wrong but it's definitively not obvious on the ms msdn class webpage.

I've never once used Image in my life. I guess it makes sense if all you want to do is render images to the screen.

Incidentally, if you're doing a lot of pixel access stuff, GH_MemoryBitmap is way faster than GetPixel/SetPixel. Also harder to use, but you can get orders of magnitude performance increase.

Fantastic! :) I don't know any better, had to process a lot of images and videos in my life. Interpolation also include, check. Tnx






  • Add Photos
  • View All

© 2020   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service