DynaPDF Manual - Page 663

Previous Page 662   Index   Next Page 664

Function Reference
Page 663 of 839
ReplaceImage
Syntax:
LBOOL pdfReplaceImage(
const PPDF* IPDF,
// Instance pointer
const PIMG* Source,
// Pointer of the image object
const char* Image,
// Path of the new image
UI32 Index,
// The first image is denoted by 1
TExtColorSpace CS,
// Image color space
SI32 CSHandle,
// Color space handle or -1 for device spaces
TReplaceImageFlags Flags) // See below.
typedef enum
{
rifDefault
= 0,
// Nothing special to do.
rifDeleteAltImages = 1,
// Delete all alternate images if any.
rifDeleteMetadata
= 2,
// Delete the meta data that was associated with the image.
rifDeleteOCG
= 4,
// Delete the Optional Content Group if any. This changes the visibility
// state of the image. Normally the OCG should be left as is.
rifDeleteSoftMask
= 8
// An image can contain a soft mask that acts as an alpha channel. This
// mask can be deleted or left as is. The mask will always be deleted if
// the new image contains an alpha channel.
}TReplaceImageFlags;
The function replaces an image with another image.
The parameter Source must be a valid pointer of an image object. This pointer is part of the
TPDFImage structure (member ObjectPtr) which is retrieved by functions like GetImageObj() or
ParseContent().
The resolution, aspect ratio, color space and so on can be freely chosen. However, note that this
function does not change the output position or size. If the aspect ratio of the new image is different,
then it will be stretched or shrunk to fit into the output rectangle.
The parameter CS specifies the destination color space into which the image should be converted or
saved, if the image is already defined in that color space. CSHandle must be the handle of that color
space if a non-device space is used. The will be ignored for devices spaces.
The function works in the very same way as InsertImageEx() with the following differences:
The color of an image mask cannot be set or changed because this would require changes on
the content stream in which the image is used. An image mask will be created if the image
color depth is 1 bit and if color key masking is enabled (see SetUseTransparency()).
SetUseTransparency() should normally be set to false before calling this function.
The image will never be downscaled, independent of the current resolution, because the size
of the output rectangle is not known.
If the image that should be replaced is a soft mask of another base image, then make sure that the
destination color space is set to esDeviceGray, CalGray, or to a one channel ICC based color space
because a soft mask must not contain more than one color channel.
 

Previous topic: ReplaceICCProfile, ReplaceICCProfileEx

Next topic: ReplaceImageEx, ReplacePageText