Creates an image XObject from a JPEG file, passed through unchanged, or returns the one this document already has for the same file.
public PdfImage CreateImageFromJpeg(ReadOnlySpan<byte> jpeg)
The JPEG file: baseline or progressive, Huffman-coded, 8-bit, with 1, 3 or 4 components.
DCTDecode stream holding exactly jpeg.
ISO 32000-2 §7.4.8 (DCTDecode, Table 13) and §8.9.5 (Table 87). Only the markers before the first scan are read: the
width, height and components come from the frame header. 1 component is DeviceGray, 3 DeviceRGB, 4
DeviceCMYK; an ICC profile in APP2 segments of the right number of components makes it ICCBased.
Four components are CMYK (YCCK when the Adobe APP14 segment says transform 2), placed as the file stores them, the way
a DCTDecode stream is read (§7.4.8): libjpeg-turbo, DctEncoder and Adobe's own DCTEncode filter write CMYK
that way, with an APP14 segment. Adobe Photoshop writes every component inverted with the same APP14 segment, so a
four-component file that also carries Photoshop's APP13 Photoshop 3.0 image resource segment, which Photoshop
writes in every JPEG file it saves, gets Decode [1 0 1 0 1 0 1 0] (§8.9.5.2). Files from other writers that invert
CMYK as Photoshop does (Pillow, ImageMagick) are byte-for-byte indistinguishable in their markers from libjpeg-turbo's and
are placed as stored.
Three components identified as R, G and B without an APP14 segment get DecodeParms << /ColorTransform 0 >>,
so they are not converted from YCbCr (Table 13). A progressive file records PDF 1.3. A mutation.