DynaPDF Manual - Page 138

Previous Page 137   Index   Next Page 139

Function Reference
Page 138 of 787
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.
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), AddRenderingIntentEx (obsolete)

Start Chat