// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // namespace ImageSharp.Formats { /// /// Defines jpeg constants defined in the specification. /// internal static class JpegConstants { /// /// The maximum allowable length in each dimension of a jpeg image. /// public const ushort MaxLength = 65535; /// /// Represents high detail chroma horizontal subsampling. /// public static readonly byte[] ChromaFourFourFourHorizontal = { 0x11, 0x11, 0x11 }; /// /// Represents high detail chroma vertical subsampling. /// public static readonly byte[] ChromaFourFourFourVertical = { 0x11, 0x11, 0x11 }; /// /// Represents medium detail chroma vertical subsampling. /// public static readonly byte[] ChromaFourTwoTwoVertical = { 0x11, 0x11, 0x11 }; /// /// Represents low detail chroma vertical subsampling. /// public static readonly byte[] ChromaFourTwoZeroVertical = { 0x22, 0x11, 0x11 }; /// /// Represents medium detail chroma horizontal subsampling. /// public static readonly byte[] ChromaFourTwoTwoHorizontal = { 0x22, 0x11, 0x11 }; /// /// Represents low detail chroma horizontal subsampling. /// public static readonly byte[] ChromaFourTwoZeroHorizontal = { 0x22, 0x11, 0x11 }; /// /// Describes component ids for start of frame components. /// internal static class Components { /// /// The YCbCr luminance component id. /// public const byte Y = 1; /// /// The YCbCr chroma component id. /// public const byte Cb = 2; /// /// The YCbCr chroma component id. /// public const byte Cr = 3; /// /// The YIQ x coordinate component id. /// public const byte I = 4; /// /// The YIQ y coordinate component id. /// public const byte Q = 5; } /// /// Describes common Jpeg markers /// internal static class Markers { /// /// Marker prefix. Next byte is a marker. /// public const byte XFF = 0xff; /// /// Same as but of type /// public const int XFFInt = XFF; /// /// Start of Image /// public const byte SOI = 0xd8; /// /// Start of Frame (baseline DCT) /// /// Indicates that this is a baseline DCT-based JPEG, and specifies the width, height, number of components, /// and component subsampling (e.g., 4:2:0). /// /// public const byte SOF0 = 0xc0; /// /// Start Of Frame (Extended Sequential DCT) /// /// Indicates that this is a progressive DCT-based JPEG, and specifies the width, height, number of components, /// and component subsampling (e.g., 4:2:0). /// /// public const byte SOF1 = 0xc1; /// /// Start Of Frame (progressive DCT) /// /// Indicates that this is a progressive DCT-based JPEG, and specifies the width, height, number of components, /// and component subsampling (e.g., 4:2:0). /// /// public const byte SOF2 = 0xc2; /// /// Define Huffman Table(s) /// /// Specifies one or more Huffman tables. /// /// public const byte DHT = 0xc4; /// /// Define Quantization Table(s) /// /// Specifies one or more quantization tables. /// /// public const byte DQT = 0xdb; /// /// Define Restart Interval /// /// Specifies the interval between RSTn markers, in macroblocks. This marker is followed by two bytes /// indicating the fixed size so it can be treated like any other variable size segment. /// /// public const byte DRI = 0xdd; /// /// Define First Restart /// /// Inserted every r macroblocks, where r is the restart interval set by a DRI marker. /// Not used if there was no DRI marker. The low three bits of the marker code cycle in value from 0 to 7. /// /// public const byte RST0 = 0xd0; /// /// Define Eigth Restart /// /// Inserted every r macroblocks, where r is the restart interval set by a DRI marker. /// Not used if there was no DRI marker. The low three bits of the marker code cycle in value from 0 to 7. /// /// public const byte RST7 = 0xd7; /// /// Start of Scan /// /// Begins a top-to-bottom scan of the image. In baseline DCT JPEG images, there is generally a single scan. /// Progressive DCT JPEG images usually contain multiple scans. This marker specifies which slice of data it /// will contain, and is immediately followed by entropy-coded data. /// /// public const byte SOS = 0xda; /// /// Comment /// /// Contains a text comment. /// /// public const byte COM = 0xfe; /// /// End of Image /// public const byte EOI = 0xd9; /// /// Application specific marker for marking the jpeg format. /// /// public const byte APP0 = 0xe0; /// /// Application specific marker for marking where to store metadata. /// public const byte APP1 = 0xe1; /// /// Application specific marker used by Adobe for storing encoding information for DCT filters. /// public const byte APP14 = 0xee; /// /// Application specific marker used by GraphicConverter to store JPEG quality. /// public const byte APP15 = 0xef; } /// /// Describes Adobe specific markers /// internal static class Adobe { /// /// The color transform is unknown.(RGB or CMYK) /// public const int ColorTransformUnknown = 0; /// /// The color transform is YCbCr (luminance, red chroma, blue chroma) /// public const int ColorTransformYCbCr = 1; /// /// The color transform is YCCK (luminance, red chroma, blue chroma, keyline) /// public const int ColorTransformYcck = 2; } } }