JPEG2000 Image Format Support

概述

HotPDF 现在提供对 JPEG2000 图像格式的完整支持,包括 JP2、J2K 和 JPT 文件。JPEG2000 是基于 wavelet 的图像压缩标准,相比传统 JPEG 格式具备更高压缩效率和质量

支持的格式

  • JP2: JPEG2000 Part 1 format with complete file structure
  • J2K: JPEG2000 codestream format (raw compressed data)

关键特性

  • Automatic format detection and appropriate processing
  • 同时支持无损和有损压缩
  • Multi-component image support (RGB, RGBA, Grayscale)
  • Advanced bit-depth support (8, 12, 16 bits per component)
  • 带瓦片网格元数据的直接已验证码流瓦片解码
  • 源区域与 2 的幂感兴趣分辨率组合解码
  • 面向恶意或意外超大码流的解码输出预算
  • 从可见目标像素自动选择渲染器分辨率
  • 对相互独立的相交瓦片进行有界并行重建
  • 确定性的合成、取消、worker 上限和峰值内存遥测

Usage Example


// Delphi example - Adding JPEG2000 image to PDF
procedure AddJPEG2000Image;
var
  PDF: THotPDF;
begin
  PDF := THotPDF.Create(nil);
  try
    PDF.FileName := 'output.pdf';
    PDF.BeginDoc;
    PDF.AddPage;

    // Add JPEG2000 image - format is automatically detected
    PDF.AddImage('sample.jp2', 100, 100, 200, 150);

    // J2K codestream format is also supported
    PDF.AddImage('sample.j2k', 100, 300, 200, 150);

    PDF.EndDoc;
  finally
    PDF.Free;
  end;
end;
        

技术实现

JPEG2000 支持通过 HPDFJpeg2000.pas 单元实现,该单元提供以下内容:

  • THPDFJpeg2000Decoder: Main decoder class for processing JPEG2000 images
  • 格式检测:自动识别 JP2、J2K 和 JPT 格式
  • 头信息检查: InspectHeaderFromByteArray 读取尺寸、分量数和 SourceColorSpace,不解码像素样本
  • 流处理:同时支持基于文件和基于流的图像加载
  • 瓦片访问: LoadTileFromByteArray 解码单个已验证的瓦片并报告其源偏移和网格
  • 分辨率选择: LoadRegionFromByteArray 将源矩形与小波缩减因子结合
  • 并行瓦片解码: LoadRegionFromByteArrayParallel 使用独立的解码器实例和确定性的按行主序合成
  • 已加载 PDF: DecodeLoadedImageRegionAtResolution 选择对任一目标维度都不会欠分辨率的级别
  • 操作控制: JPEG2000ParallelTileDecoding 和 JPEG2000TileWorkerLimit 控制渲染器集成,GetLastJPEG2000ParallelDecodeStats 报告调度与预算估算
  • OpenJPEG Integration:在 Win32 和 Win64 上进行原生链接解码

性能优势

  • Better compression ratios than traditional JPEG
  • No blocking artifacts at high compression rates
  • Progressive transmission and viewing
  • Region of interest (ROI) encoding support
  • 可见区域跨越独立码流瓦片时的并发重建
  • Lossless compression option

Compatibility

JPEG2000 支持在 HotPDF 的 32-bit 和 64-bit 版本中都可用,并兼容所有受支持 Delphi 和 C++ Builder 版本

另请参阅