Last Updated: 06 Jun 2017 13:45 by ADMIN
Created on: 06 Jun 2017 13:41
Category: PDFViewer
Type: Bug Report
PdfViewer: CMYK JPEG image is rendered incorrect when BitmapImage is initialized with PixelFormat differing from CMYK
Default DctDecode implementation uses System.Windows.Media.Imaging.BitmapImage in order to get the image pixels. However, when the image uses some complex colorspace (for instance Separation based on CMYK) the BitmapImage is initialized with a different format and we use System.Windows.Media.Imaging.FormatConvertedBitmap in order to get the pixels in CMYK colorspace. There seems to be some issue with these calculations as the resulting image has incorrect pixels.

WORKAROUND: You may inherit DctDecode class in order to implement custom decoder and call DecodeWithJpegDecoder method from the base class as mentioned in the note of this documentation article:


A sample implementation of these custom decoder may be seen below:

public class CustomDctDecode : DctDecode
    public override byte[] Decode(PdfObject decodedObject, byte[] inputData, DecodeParameters parms)
        return DecodeWithJpegDecoder(inputData);