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