JpegSegments

Ecng.Drawing

Reads the JPEG segments both decoders understand the same way: tables, the frame header and the application segments that say how the samples are to be shown.

Properties

ProfileSignature
public static ReadOnlySpan<byte> ProfileSignature { get; }
value = JpegSegments.ProfileSignature

What an APP2 segment that holds a part of an ICC profile starts with; the number of the part and the number of parts follow, a byte each.

Methods

EnsureEnoughData
public static void EnsureEnoughData(int width, int height, int remaining)
JpegSegments.EnsureEnoughData(width, height, remaining)

Refuses a file too short to hold the picture it declares, before buffers are allocated for it.

width
Width of the picture.
height
Height of the picture.
remaining
Bytes of the file that follow the header being read.
IsJfif
public static bool IsJfif(ReadOnlySpan<byte> segment)
result = JpegSegments.IsJfif(segment)

Whether an APP0 segment is the JFIF header.

ReadFrame
public static JpegComponent[] ReadFrame(ReadOnlySpan<byte> segment, int width, int height)
result = JpegSegments.ReadFrame(segment, width, height)

Reads a frame header: the size of the picture and its components with their block grids.

ReadHuffmanTables
public static void ReadHuffmanTables(ReadOnlySpan<byte> segment, JpegHuffmanTable[] dc, JpegHuffmanTable[] ac)
JpegSegments.ReadHuffmanTables(segment, dc, ac)

Reads the Huffman tables of a DHT segment.

ReadOrientation
public static int ReadOrientation(ReadOnlySpan<byte> data)
result = JpegSegments.ReadOrientation(data)

Reads the Exif orientation of a JPEG.

Returns: A value from 1 to 8; 1 - the picture is stored the way it is shown - if the file says nothing readable.

ReadProfile
public static byte[] ReadProfile(ReadOnlySpan<byte> data)
result = JpegSegments.ReadProfile(data)

Reads the ICC profile of a JPEG: the parts its APP2 segments hold, put together.

Returns: The profile if it is one that can go into a re-encoded picture (see Byte})); otherwise - and if the file has none, or its parts do not make a whole - empty.

ReadQuantizationTables
public static void ReadQuantizationTables(ReadOnlySpan<byte> segment, int[][] tables)
JpegSegments.ReadQuantizationTables(segment, tables)

Reads the quantization tables of a DQT segment, each into natural order.

TryReadAdobeTransform
public static bool TryReadAdobeTransform(ReadOnlySpan<byte> segment, int transform)
result = JpegSegments.TryReadAdobeTransform(segment, transform)

Reads the color transform flag of an APP14 segment.

Returns: if the segment is not Adobe's.

Fields

Adobe
public const int Adobe
value = JpegSegments.Adobe

APP14: the Adobe segment.

Exif
public const int Exif
value = JpegSegments.Exif

APP1: Exif.

Jfif
public const int Jfif
value = JpegSegments.Jfif

APP0: the JFIF header.

Profile
public const int Profile
value = JpegSegments.Profile

APP2: a part of an ICC profile.