WPF BitmapImage and TIFF with CMYK + Alpha

I use this code snippet to upload various image files:

BitmapImage bitmap = new BitmapImage ();
bitmap.BeginInit ();
bitmap.UriSource = new System.Uri (path);
bitmap.CreateOptions = BitmapCreateOptions.PreservePixelFormat;
bitmap.EndInit ();

This works great for TIFF files stored as RGB, RGB + Alpha and CMYK. 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 a valid decoder).

Earlier, I used the FreeImage library and the C # thin shell on top of it. FreeImage 3.x has partial support for this image format, i.e. I had to download TIFF twice as CMYK without transparency and once as RGB + Alpha; this trick is necessary because FreeImage provides access to no more than 4 simultaneous color channels.

I would like to know if there is a way to download CMYK + Alpha bitmaps? Either directly in C #, or through some interaction code, but preferably without using a third-party DLL (except for .NET.NET libraries).

An example of such a TIFF file can be found here .

EDIT : I can no longer reproduce the problem, the following code works very well:

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);

But I'm still stuck: how can I find out that the original image was encoded as a CMYK plus Alpha channel? When you look at a property Format, I only get information that the image has 40 bits per pixel. All interesting things are stored in the following non-public properties:

bitmap.Format.FormatFlags == IsCMYK | NChannelAlpha;
bitmap.Format.HasAlpha == true;

Is there an official way to get to them without resorting to thought?

+5
3

, : tiff png24, .

Photoshop , CMYK Tiff "Transparency": " TIFF. ?"

, .

, http://msdn.microsoft.com/en-us/library/system.drawing.imageconverter.aspx , , , , .

.

0

, GDI + .

System.Drawing.Image ..

interop, GDI + WPF.

0

I found another question about SO that is related to this library:

http://freeimage.sourceforge.net/

Good Tiff Library for .NET

Hope this helps.

0
source

All Articles