# JPEG 2000 Format

# JPEG 2000 Format

JPEG 2000 is a wavelet-based image compression standard. It was created by the Joint Photographic Experts Group committee as a replacement for their own DCT based JPEG standard. JPEG 2000 can operate at higher compression ratios without generating 'blocky and blurry' artifacts of the older JPEG standard. Nowadays JPEG 2000 is not as widely supported as its predecessor. Common file name extensions are .jp2, .j2c, and .j2k (for code stream only).
As of version 0.24.2 Imaging uses OpenJPEG library compiled to object files (Delphi) or static libraries (FPC) and linked to Object Pascal program. Therefore, JPEG 2000 support is not a part of core library (not native Pascal) now and is located in Extras package. Currently Imaging supports JPEG 2000 on Win32 (for Delphi and FPC) and Linux systems (FPC only - no Kylix support). For Linux there are precompiled objects for x86 and x86_64 architectures.
JPEG 2000 supports wide variety of data formats. You can have arbitrary number of components/channels, each with different bitdepth and optional "signedness". JPEG 2000 images can be lossy or lossless compressed. Imaging can load most data formats (except multichannel images with component bitdepth > 16 => no Imaging data format equivalents). Components with sample separation are loaded correctly, ICC profiles or palettes are not used, YCbCr images are translated to RGB.

## JPEG 2000 File Format Support

Format | TImageFormat equivalent | Loading | Saving
--- | --- | --- | ---
8 bit grayscale | ifGray8 | Yes | Yes
16 bit grayscale | ifGray16 | Yes | Yes
32 bit grayscale | ifGray32 | Yes | Yes
8 bit grayscale + alpha | ifA8Gray8 | Yes | Yes
16 bit grayscale + alpha | ifA16Gray16 | Yes | Yes
24 bit RGB | ifR8G8B8 | Yes | Yes
48 bit RGB | ifR16G16B16 | Yes | Yes
32 bit ARGB | ifA8R8G8B8 | Yes | Yes
64 bit ARGB | ifA16R16G16B16 | Yes | Yes

JPEG 2000 offers vast amount of channel count and bitdepth combinations but formats listed in table are the most common ones.

When working with JPEG 2000 files you can find useful some options which can be set by SetOption function and their current values can be get by GetOption function. Or you can set them by modifying properties of TJpeg2000FileFormat class.

## Options Related to JPEG 2000 Files

OptionId | Allowed Values | Usage
--- | --- | ---
ImagingJpeg2000Quality | 1 to 100 | JPEG 2000 compression quality used when saving images. Higher value means worse compression/better image quality/larger file size. Default value is 80.
ImagingJpeg2000CodeStreamOnly | 0 (False) or 1 (True) | Controls whether JPEG 2000 image is saved with full file headers or just as code stream. Default value is False (0).
ImagingJpeg2000LosslessCompression | 0 (False) or 1 (True) | Specifies JPEG 2000 image compression type. If True (1), saved JPEG 2000 files will be losslessly compressed. Otherwise lossy compression is used. Default value is False (0).