Search code examples
c#.netgdi+color-management

Apply an ICC Color Profile to an image in C# (Dotnet)


How does one convert an image from one color profile to another (screen to printer, or scanner to screen). In Visual C++ you would use the function in ICM.h, is there a managed way to do this with GDI+?

I need to use GDI+, not WPF. I'd prefer to have a managed solution, but if it is not available, I guess PInkvoke will have to suffice.


Solution

  • There are a number of solutions.

    1. For GDI+, check out this article at MSDN (HOW TO: Use GDI+ and Image Color Management to Adjust Image Colors).
    2. For WPF (.NET 3.0), see the System.Windows.Media namespace. There are a number of different classes, such as the BitmapEncoder, that have the concept of a ColorContext, which "Represents the International Color Consortium (ICC) or Image Color Management (ICM) color profile that is associated with a bitmap image."

    Both of these seem pretty complex, so there's always the option of buying somebody else's code. Atalasoft's DotImage Photo Pro has ICC profile setting capabilities built in. The code is expensive; a dev license is almost 2k. But based on their participation in the dotnet community, I'd give them a whirl.