Assign an ICC Color Profile to an image in C#
Asked Answered
L

1

6

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.

Lili answered 17/2, 2012 at 10:30 Comment(0)
V
7

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.

Valid answered 24/2, 2012 at 12:42 Comment(3)
I am using Aspose.Pdf.Kit for the conversion of PDF page to System.Windows.Image and that function does not offer the option to keep the color profile. But I am currently looking into the libraries you suggested.Lili
This (free image library) solved the problem I asked, but now I have another, I'll award the bounty in 17 hours.Lili
@Lili - it's great that the library helped. I keep meaning to do more with it myself, as it seems very flexible. Sorry you've come up against a new issue, though :(Valid

© 2022 - 2024 — McMap. All rights reserved.