GDI+ supports the following image flags:
Code:
ColorSpaceRgb = 16,
ColorSpaceCmyk = 32,
ColorSpaceGray = 64,
ColorSpaceYcbcr = 128,
ColorSpaceYcck = 256,
For your file, the flag ColorSpaceRgb is set. I presume under Windows XP the flag ColorSpaceYcck is set and image shows correctly.
PDFsharp lets Windows analyze the file. This sometimes fails under Windows 7 (and later).
Adobe Reader also does not analyze the file, it relies on the flags given in the PDF file.
If all your JPEG files are CMYK, then go to PdfImage.cs, method InitializeJpeg and replace this line
Code:
Elements[Keys.ColorSpace] = new PdfName("/DeviceRGB");
with those:
Code:
Elements[Keys.ColorSpace] = new PdfName("/DeviceCMYK");
Elements["/Decode"] = new PdfLiteral("[1 0 1 0 1 0 1 0]");
If you use both RGB and CMYK JPEGs: sorry, I currently have no idea.
BTW: That image is a good candidate for lossless compression (e.g. PNG) instead of JPEG. Might even reduce the file size.
Re different sizes:
zoranm80 wrote:
count = sourceFile.Read(buffer, 0, buffer.Length);
memory.Write(buffer, 0, buffer.Length);
The second line should be
Code:
memory.Write(buffer, 0, count)
This resolves the size difference - but image still doesn't work.