Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

DynaPDF Manual - Page 483

Previous Page 482   Index   Next Page 484

Function Reference
Page 483 of 750
How to calculate the image size?
The calculation of the image size should be easy as possible. In most cases, images must be inserted
with exact proportions. Therefore, all image functions support two special values to make the
calculation easier. The width and height can be calculated as follows:
If ScaleWidth or ScaleHeight is -1 the function uses the original width or height from the image.
If both parameters are -1 the image will be inserted with a resolution of 72 DPI.
If ScaleWidth or ScaleHeight is 0, the missing value is calculated in relation to the given value
of ScaleHeight or ScaleWidth to preserve the image's aspect ratio. The resulting output is an
image with exact proportions relative to its original size.
If ScaleWidth and ScaleHeight is 0, the original size is used (same effect as -1).
A negative value of Width or Height mirrors the image on the x- and or y-axis.
Image Resolution
Images will be scaled to the defined resolution (see SetResolution()) if the original size is larger than
required, and if the property SaveNewImageFormat is set to true (default).
Images are downscaled with a high quality scaling algorithm to avoid loss of image quality.
However, 1 bit images are never downscaled because the loss of quality can be very large.
If the image resolution is only a little bit larger than required, the new image can require more disk
space than the original unscaled image. This is an effect of the color interpolation because scaled
images contain usually more colors than the original image.
However, to avoid the above effect the original image must be at least 5% larger than required before
the image will be scaled.
Transparent images (Color Key Masking)
DynaPDF masks images without an alpha channel with color key masking by default. Color key
masking is natively supported in GIF images only. Therefore, it is recommended to disable image
transparency by default since it is automatically applied on GIF images if necessary.
That color key masking is enabled by default is an artifact of older DynaPDF versions which didn't
support alpha transparency. Use the function SetUseTransparency() to enable or disable color key
masking.
Notice:
If an image will be downscaled to the whished resolution, it is possible that the transparent color
does no longer produce the whished transparency effect. This can occur due to color
interpolation during downscaling. To avoid such issues set the resolution to a higher value or
disable downscaling with the function SetSaveNewImageFormat(). Color key masking does also
not properly work with JPEG or JPEG 2000 compressed images since these filters are lossy filters
which change color values.
 

Previous topic: GIF images

Next topic: Images with an alpha channel