Table of Contents

Class JpegImageDecoder

Namespace
DocWright.Core.Imaging
Assembly
DocWright.Core.dll

A self-contained baseline JPEG decoder.

public static class JpegImageDecoder
Inheritance
JpegImageDecoder
Inherited Members

Remarks

Why this exists. The PDF renderer never needed to decode a JPEG: PDF carries one verbatim as a /DCTDecode stream and lets the viewer decode it. A raster renderer has no such luxury — it has to produce the pixels itself. Phase 17's inventory expected to find a decoder to share and found only a frame-header parser, so this is net-new.

Scope. Sequential and progressive DCT, 8-bit, Huffman coded: SOF0, SOF1 and SOF2, one to four components, any sampling factors, restart intervals. Grayscale, YCbCr, CMYK and Adobe YCCK are converted. Lossless, arithmetic and hierarchical frames are still refused with a reason.

Two scan walks, one everything else. A sequential frame carries every coefficient in a single scan, so it dequantizes and inverse-transforms each block the moment it has read it and never buffers a coefficient. A progressive frame spreads the same coefficients over many scans — the spectral band split across scans, and each band's bits delivered by successive approximation — so no block is complete until the last scan has been read, and that path accumulates into a per-component coefficient buffer and transforms once at the end. The two share the frame parser, the Huffman tables, the bit reader, the inverse DCT and the colour composition. Only the scan walk differs, because that is the only thing that actually does.

Determinism. The inverse DCT is the standard integer (fixed-point) algorithm, not a float one, so decoding is bit-exact and identical on every runtime — which the renderer's byte-identical-output contract requires of everything it composites.

Methods

HasSignature(byte[])

Returns true when the bytes begin with the JPEG SOI marker.

TryDecode(byte[], out DecodedRasterImage?, out string)

Decodes a baseline JPEG image.

TryDecode(byte[], long, out DecodedRasterImage?, out string)

Decodes a JPEG, refusing an image whose declared dimensions pass a pixel budget.