Xojo Conferences
MBSOct2019CologneDE

DynaPDF Manual - Page 134

Previous Page 133   Index   Next Page 135

Function Reference
Page 134 of 770
AddRasImage (Rendering Engine)
Syntax:
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
{
cfFlate
= 0x00000000, // TIFF output
cfJPEG
= 0x00000001, // JPEG, or TIFF output
cfCCITT3
= 0x00000002, // B&W CCITT Fax G3 compression
cfCCITT4
= 0x00000003, // B&W CCITT Fax G4 compression -> higher compression ratio
cfLZW
= 0x00000004, // Very fast but less compression ratios than flate
cfLZWBW
= 0x00000005, // TIFF -> Floyd Steinberg dithering
cfFlateBW
= 0x00000006, // TIFF, PNG, or BMP output -> Floyd Steinberg dithering
cfJP2K
= 0x00000007, // JPEG2000 output
// These flags can be combined with the filters cfFlate, cfCCITT3, cfCCITT4, and LZW.
cfDitherFloydSteinberg
= 0x00001000, // See 1 bit image output below
cfConvGrayToOtsu
= 0x00002000
// See 1 bit image output below
}TCompressionFilter;
The function adds an image from the rasterizer to the current open image file. The output image
must be opened with CreateImage() beforehand.
The function performs a color conversion if the output image format requires another component
order. For example, if the pixel format of the rasterizer is RGB and if the output image format is BMP
then the component order must be changed to BGR because Windows Bitmaps require the
component order BGR. This conversion must be considered if the image buffer should be passed to
another function.
Windows Bitmaps require double word aligned scanlines while all other image formats support byte
aligned the scanlines. 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.
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.
However, most OCR engines have problems to identify glyphs in dithered images. For this purpose,
the Otsu filter is the best choice. This filter produces true black & white output. It does not try to
simulate gray shades by dithering areas of the image. If you want to apply an OCR scan then filter is
the one you should use.
There are two ways to apply the Floay Steinberg dithering algorithm: either combine the flag
cfDitherFloydSteinberg with the compression filter you want to use:
 

Previous topic: AddPageLabel

Next topic: Compression filters, AddRenderingIntent (obsolete)