Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF BitmapImage and TIFF with CMYK + Alpha
    primarykey
    data
    text
    <p>I am using this code snippet to load various image files:</p> <pre><code>BitmapImage bitmap = new BitmapImage (); bitmap.BeginInit (); bitmap.UriSource = new System.Uri (path); bitmap.CreateOptions = BitmapCreateOptions.PreservePixelFormat; bitmap.EndInit (); </code></pre> <p>This works fine for TIFF files stored as RGB, RGB+Alpha and CMYK. <strike>However, if I try to load a TIFF file using CMYK colors and an alpha channel, I get an exception (the file format is not recognized as being valid by the decoder).</strike></p> <p>I was previously using the <a href="http://freeimage.sourceforge.net/" rel="nofollow">FreeImage</a> library and a thin C# wrapper on top of it. FreeImage 3.x has partial support for this kind of image format, i.e. I had to load the TIFF twice, once as CMYK without transparency and once as RGB+Alpha; this trick is needed since FreeImage only gives access to at most 4 simultaneous color channels.</p> <p><strike>I'd like to know if there is a supported way to load CMYK+Alpha bitmaps? Either directly in C# or by going through some interop code, but preferably without having to use a third-party DLL (other than the .NET 4 framework libraries).</strike></p> <p>An example of such a TIFF file can be found <a href="http://www.opac.ch/files/cmyka.tif" rel="nofollow">here</a>.</p> <p><strong>EDIT</strong> : I can no longer reproduce the problem, the following code works just fine:</p> <pre><code>BitmapImage bitmap = new BitmapImage (); bitmap.BeginInit (); bitmap.UriSource = new System.Uri (path); bitmap.CreateOptions = BitmapCreateOptions.PreservePixelFormat; bitmap.EndInit (); byte[] pixels = new byte[bitmap.PixelHeight*bitmap.PixelWidth*5]; bitmap.CopyPixels (pixels, bitmap.PixelWidth * 5, 0); </code></pre> <p>But I am still stuck: how can I find out that the source image was encoded as CMYK plus Alpha channel? When looking at the <code>Format</code> property, I get only the information that the image has 40 bits per pixel. All the interesting stuff is stored in the following non-public properties:</p> <pre><code>bitmap.Format.FormatFlags == IsCMYK | NChannelAlpha; bitmap.Format.HasAlpha == true; </code></pre> <p>Is there any official way of getting to them, without resorting to reflection?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload