DynaPDF Manual - Page 545

Previous Page 544   Index   Next Page 546

Function Reference
Page 545 of 839
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).
To insert an image from a file buffer use the function InsertImageFromBuffer(). It is possible to use
one image on several pages or positions. To insert an image multiple times use the function
PlaceImage(). However, once an image was inserted, the physical dimension cannot be changed
anymore; it can only be scaled to different sizes. If an image should be used with different
dimensions, insert the largest version first or insert it again with this function.
DynaPDF checks whether an image was already inserted before inserting an image again. The
duplicate check is done by using a MD5 hash of the file name and the used parameters to insert the
image. If all parameters are the same, the already available image is used instead.

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

Next topic: InsertImageFromBuffer