Eto.Drawing invert colors of bitmap or image?

Hi there,

is it possible to invert the colors of a bitmap or image using Eto.Drawing ?

I mean without iterating pixel by pixel…

thanks,
clement

Check this piece of code where I use System.Drawing.Bitmap to convert to grayscale

Specifically see the color conversion matrix starting on line 258 and it being applied on 277 to the image attributes and those attributes themselves in turn being used on 323.

Hi @nathanletwory, thank you. I guess there is no equivalent to this:

attr = System.Drawing.Imaging.ImageAttributes()
attr.SetRemapTable(my_color_map)

using Eto ?

_
c.

I don’t think so, I would just use the System.Drawing and System.Drawing.Imaging namespaces, and then convert to an Eto bitmap when done.

Thanks @nathanletwory, i’m not sure if this needs to work on Mac in the future, hence my question for an Eto only way to accomplish it.

_
c.

The code I linked you to also works on Mac as RhinoCycles runs there no problem.

1 Like

Thanks @nathanletwory, these are good news. I’ll use SetRemapTable then.

_
c.

SetRemapTable comes from gdiplus, which is kind of unsupported after .NET 6.0. I don’t know whether Rhino has hacks on macos.

Hi @gankeyu, thank you for this information. I’ll try what i can do on mac. I’m also looking for a replacement of System.Drawing.Drawing2D.PathGradientBrush then…

_
c.

I don’t know about hacks, that is something I can’t speak to, I just use what I can. Maybe @curtisw can tell more about that.

I just know that the code works in Rhino. Here Rhino 8.7 with a wallpaper set to grayscale, which uses the code that I showed: