Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Assign an ICC Color Profile to an image in C#

In short: I want to assign a ICC color profile to an image and not apply it.

More info: In my company we need to merge a multiple layered pdf file into one layer. To do this we merge the pdf page into an image and then save the image as a pdf. But in the process of creating the image the color profile of the image gets lost. If we Apply the color profile in C# the profile will transform from Device RGB (default output of .NET) to the sRGB_IEC61966-2-1_no_black_scaling.icc profile. In the transformation some colors change. Instead of applying the color profile we need to assign it. Meaning that no colors are transformed.

Does anyone know how to achieve this? Thanks in advance.

like image 577
SynerCoder Avatar asked Feb 17 '12 10:02

SynerCoder


People also ask

How do you set a color profile?

To assign a color profile to a device, go to the Devices tab, and select your display device in the Device drop-down. Select the Use my settings for this device checkbox. This lets you make changes to that device's color profile settings.

Where is ICC color profile located?

Go to System Preferences → Displays → and select the Color tab. Then click the ICC profile you want to check and click the.


1 Answers

Before you start working on your bitmap (i.e. before you commence the layout of the individual PDF components), ensure that the bitmap has your target ICC profile applied. You say that your individual pictures have the required profile embedded within them, and this is being lost in the transformation. To retain the profile, ensure that you use the following load method, which respects any colour profile info:

http://msdn.microsoft.com/en-us/library/4sahykhd.aspx

You can use this first bitmap as the target for your composition work, then export it later. It should retain the original ICC profile.

Alternatively, you can use the FreeImage or ImageMagick libraries to manage colour profiles explicitly. They both have .NET wrappers and allow for stripping/applying of ICC profile files:

Free Image Library

Image Magick Command-Line Profile Options

Image Magick .NET Wrapper

I hope this helps.

like image 188
Dave R. Avatar answered Oct 10 '22 15:10

Dave R.