|
JPEG2000 Image Format Support
Overview
HotPDF provides comprehensive support for JPEG2000 image formats, including JP2 and J2K files
JPEG2000 is a wavelet-based image compression standard that provides superior compression efficiency and
quality compared to traditional JPEG format
Supported Formats
- JP2: JPEG2000 Part 1 format with complete file structure
- J2K: JPEG2000 codestream format (raw compressed data)
Key Features
- Automatic format detection and appropriate processing
- Support for both lossless and lossy compression
- Multi-component image support (RGB, RGBA, Grayscale)
- Advanced bit-depth support (8, 12, 16 bits per component)
- Direct validated codestream-tile decoding with tile-grid metadata
- Combined source-region and power-of-two resolution-of-interest decoding
- Decoded-output budgets for hostile or unexpectedly large codestreams
- Automatic renderer resolution selection from visible target pixels
- Bounded parallel reconstruction of independent intersecting tiles
- Deterministic composition, cancellation, worker-limit, and peak-memory telemetry
Usage Example
// Delphi example - Adding JPEG2000 image to PDF
procedure AddJPEG2000Image;
var
PDF: THotPDF;
ImageIndex: Integer;
begin
PDF := THotPDF.Create(nil);
try
PDF.FileName := 'output.pdf';
PDF.BeginDoc;
PDF.AddPage;
// Add a JPEG2000 image - the .jp2 source is decoded and then embedded
// with the requested compression
ImageIndex := PDF.AddImage('sample.jp2', icFlate);
PDF.CurrentPage.ShowImage(ImageIndex, 100, 100, 200, 150, 0);
// J2K codestream format is also supported
ImageIndex := PDF.AddImage('sample.j2k', icFlate);
PDF.CurrentPage.ShowImage(ImageIndex, 100, 300, 200, 150, 0);
PDF.EndDoc;
finally
PDF.Free;
end;
end;
Technical Implementation
The JPEG2000 support is implemented through the HPDFJpeg2000.pas unit, which provides:
- THPDFJpeg2000Decoder: Main decoder class for processing JPEG2000 images
- Format Detection: Automatic identification of JP2, J2K, and JPT formats
- Header Inspection:
InspectHeaderFromByteArray reads dimensions, components and SourceColorSpace without decoding pixel samples
- Stream Processing: Support for both file and stream-based image loading
- Tile Access:
LoadTileFromByteArray decodes one validated tile and reports its source offset and grid
- Resolution Selection:
LoadRegionFromByteArray combines a source rectangle with a wavelet reduction factor
- Parallel Tile Decode:
LoadRegionFromByteArrayParallel uses independent decoder instances and deterministic row-major composition
- Loaded PDFs:
DecodeLoadedImageRegionAtResolution selects a level that does not under-resolve either target dimension
- Operation Controls:
JPEG2000ParallelTileDecoding and JPEG2000TileWorkerLimit control renderer integration, while GetLastJPEG2000ParallelDecodeStats reports scheduling and budget estimates
- OpenJPEG Integration: Native linked decoding on Win32 and Win64
Performance Benefits
- Better compression ratios than traditional JPEG
- No blocking artifacts at high compression rates
- Progressive transmission and viewing
- Region of interest (ROI) encoding support
- Concurrent reconstruction when a visible region crosses independent codestream tiles
- Lossless compression option
Compatibility
JPEG2000 support is available in both 32-bit and 64-bit versions of HotPDF and is compatible with
all supported Delphi and C++ Builder versions
See Also
|