Xojo Conferences

DynaPDF Manual - Page 496

Previous Page 495   Index   Next Page 497

Function Reference
Page 496 of 770
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
If an image will be downscaled to a lower resolution, it is possible that the transparent color does
no longer produce the wished 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.
Images with an alpha channel
Images which contain an alpha channel are always inserted transparent, independent of the current
value of SetUseTransparency(). If an image with an alpha channel should appear opaque then draw
a rectangle in the wished background color in background of it (just before inserting the image).

Previous topic: Bitmap images, GIF images, How to calculate the image size?

Next topic: InsertImageFromBuffer