DynaPDF Manual - Page 582

Previous Page 581   Index   Next Page 583

Function Reference
Page 582 of 777
LBOOL pdfReadImageFormat2(
const PPDF* IPDF,
// Instance pointer
const char* FileName,
// File path to image
UI32 Index,
// Image index of multi-page image
UI32 ADDR Width,
// Width of the image in pixel
UI32 ADDR Height,
// Height of the image in pixel
SI32 ADDR BitsPerPixel, // Color depth
SI32 ADDR UseZip)
// If true, Flate compression should be used
The function retrieves the most important properties of an image file. All parameters of the function
must not be NULL. The function reads only the image header to improve processing speed. The
parameter UseZip determines whether Flate compression produces probably better compression
results for this image format. If the parameter BitsPerPixel is 32 the image is a CMYK image. Note
that TIFF images support color depths up to 64 bits per pixel. The parameter Index specifies the array
index of a multi-page image that should be read in; numbering starts at 1. The parameter is ignored
for non-multi-page image formats.
1 bit images
1 bit images use sometimes different resolutions for the x- and y-axis. This function returns the
logical size of the image taking the image resolution into account but note that this adjustment is
done for 1 bit images only. All functions to insert an image consider this adjustment in the very same
way. So, you can work with the image as if the resolution for the x- and y-axis would be identically.
However, sometimes we need the physical size of the image and this size can be calculated as
SI32 bits, useZip;
UI32 resX = 0, resY = 0, physHeight, physWidth, w, h;
pdfReadImageFormat2(pdf, "test.tif", 1, w, h, bits, useZip);
pdfReadImageResolution(pdf, "test.tif", 1, resX, resY);
if (resX != resY && resX > 0 && resY > 0){
if (resX > resY){
= w;
physHeight = h / (resX / resY);
= w / (resY / resX);
physHeight = h;
physHeight = h;
= w;
Note that the above calculation uses integer arithmetic. It is meaningful for 1 bit images only.
Return values:
If the function succeeds the return value is 1 and the parameters are filled with values. If the function
fails the return value is 0.

Previous topic: ReadImageFormat (obsolete)

Next topic: ReadImageFormatEx, ReadImageFormatFromBuffer