Xojo Conferences

DynaPDF Manual - Page 133

Previous Page 132   Index   Next Page 134

Function Reference
Page 133 of 766
AddRasImage (Rendering Engine)
LBOOL pdfAddRasImage(
const PPDF* IPDF,
// PDF Instance pointer
IRAS* RasPtr,
// Instance pointer of the rasterizer
TCompressionFilter Filter) // Compression filter for TIFF output
typedef enum TCompressionFilter
= 0x00000000, // TIFF output
= 0x00000001, // JPEG, or TIFF output
= 0x00000002, // B&W CCITT Fax G3 compression
= 0x00000003, // B&W CCITT Fax G4 compression -> higher compression ratio
= 0x00000004, // Very fast but less compression ratios than flate
= 0x00000005, // TIFF -> Floyd Steinberg dithering
= 0x00000006, // TIFF, PNG, or BMP output -> Floyd Steinberg dithering
= 0x00000007, // JPEG2000 output
// These flags can be combined with the filters cfFlate, cfCCITT3, cfCCITT4, and LZW.
= 0x00001000, // See 1 bit image output below
= 0x00002000
// See 1 bit image output below
The function adds an image from the rasterizer to the current open image file. The output image
must be opened with CreateImage() beforehand.
Note that the function performs no color conversion when the pixel format of the rasterizer is
incompatible to the output image format. For example, Windows Bitmaps support the pixel formats
BGR, or BGRA while all other image formats require pixels in the natural component order, e.g. RGB
or RGBA.
The caller must make sure that the image buffer of the rasterizer is defined in the correct component
order. If necessary swap the pixels before calling the function.
Windows Bitmaps require double word aligned scanlines while for all other image formats the
scanlines can be byte aligned. AddRasImage() adds required fill bytes automatically to achieve the
required line alignment. However, to increase conversion speed the image buffer should consider
the scaline alignment of the output image format.
The pixel format pxfCMYK and pxfCMYKA are supported by the TIFF and JPEG encoders only.
Because the JPEG encoder requires an inverted CMYK image as input, the function must invert the
image buffer for this image format. This must be considered if the image buffer should be passed to
another function after AddRasImage() was called.
TIFF is the one and only multi-page image format. All other image formats support exactly one
image. The image must be closed with CloseImage() when finish.
1 bit image output
If the pixel format of the rasterizer was set pxfGray it is possible convert the image buffer to 1 bit
black & white with the Floyd Steinberg dithering algorithm or with the Otsu filter. The Floyd
Steinberg dithering algorithm produces better results in comparison to a simple dither matrix.

Previous topic: AddPageLabel

Next topic: AddRenderingIntent (obsolete)