Xojo Conferences

DynaPDF Manual - Page 493

Previous Page 492   Index   Next Page 494

Function Reference
Page 493 of 770
JPEG images are inserted in path-through mode if either the property SetSaveNewImageFormat() is
set to false (default = true) or if no further conversion or downscaling is required.
JPEG 2000 (Experimental)
JPEG 2000 is a compression method that supports loss-less and lossy compression. It produces very
good compression rates for color and gray scale images, and it can be used with all color depths and
supported color spaces.
The loss-less variant is used if the JPEG quality is set to 0 or 1000 (see below). However, the
compression ratio of loss-less JPEG 2000 compression is not very high and Flate compression
produces mostly much better compression ratios and it is up to 30 times faster.
The lossy variant of JPEG 2000 compression supports two different compression methods: Real-
Mode and Integer-Mode, which produces slightly different output at high compression rates. The
resulting image looks slightly smoother if Real-Mode is used. The compression method can be
adjusted with SetCompressionLevel(). The Real-Mode is used if the compression level is set to clMax,
otherwise the Integer-Mode is used. However, the compression level does not change the
compression ratio in this case.
The compression ratio can be adjusted with SetJPEGQuality(). The name "JPEG Quality" refers
normally to the JPEG compression filter, however, the value has a completely different meaning
when using JPEG 2000 compression.
The property JPEG quality can be in the range from 0 to 1000, but it does not adjust the loss of
quality; it is used as a divisor of the raw uncompressed image data size to the wished compressed
image data size. This makes the usage very complicated and it is practically impossible to find a
suitable mathematically function that produces good results in most cases.
The value 1000 means that loss-less compression should be used. Lower values are used as follows:
compressed_image_size = uncompressed_raw_size * JPEGQuality / 1000
Lower values produces higher compression rates but worse image quality.
Another disadvantage of the filter is the bad compression speed. This is maybe a result of the bad
design of the used Jasper library, but it seems that JPEG 2000 compression is generally slow. Other
commercial JPEG 2000 libraries are about 2 times faster, but this is still incredible slow in comparison
to JPEG compression. In addition, the resulting image quality is practically identically with JPEG
compression if the same compression ratio was achieved.
JPEG 2000 images can contain an embedded ICC profile that can be used to create an ICC based
color space for the image (ICC based color spaces are device independent). To enable the usage of
embedded ICC profiles set the flag gfUseImageColorSpace with SetGStateFlags(). See also Color
Spaces and Images.

Previous topic: JPEG Encode, Real pass-through mode, Embedded ICC profiles, Optimized Huffmann encoding

Next topic: Why does DynaPDF not support LZW compression?, TIFF images, 1 Bit TIFF images