The thing is, that i need to create PDFs converted to the CMYK color space (best case: by specifying an ICC profile for the color conversion).
My idea so far:
Code:
private void RenderImage(Image image, XGraphics graphics, double x, double y, double width, double height)
{
Bitmap bitmap = new Bitmap(image);
MemoryStream inStream = new MemoryStream();
bitmap.Save(inStream, ImageFormat.Png);
inStream.Position = 0;
BitmapSource source = BitmapFrame.Create(inStream);
FormatConvertedBitmap convertingImage = new FormatConvertedBitmap();
convertingImage.BeginInit();
convertingImage.Source = source;
convertingImage.DestinationFormat = PixelFormats.Cmyk32;
convertingImage.EndInit();
BitmapEncoder encoder = new JpegBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(convertingImage));
MemoryStream outStream = new MemoryStream();
encoder.Save(outStream);
XImage xImage = new XImage(outStream);
xImage.Interpolate = false;
graphics.DrawImage(xImage, x - 1, y - 1);
}
Writing the image like this results in some sort of "mashed" RGB image in the PDF. I already found some advice you offer in order to obtain a "regular" image, which i suppose would still be RGB.
When i use a FileStream instead of the MemoryStream in line 19, the image is exported as a CMYK image.
Is there eventually sg. wrong inside the XImage or the XGraphics?