DynaPDF Manual - Page 592

Previous Page 591   Index   Next Page 593

Function Reference
Page 592 of 787
ReadImageFormat2
Syntax:
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
follows:
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){
physWidth
= w;
physHeight = h / (resX / resY);
}else{
physWidth
= w / (resY / resX);
physHeight = h;
}
}else{
physHeight = h;
physWidth
= w;
}
Note that the above calculation uses integer arithmetic. It is meaningful for 1 bit images only.
 

Previous topic: ReadImageFormat (obsolete)

Next topic: ReadImageFormatEx, ReadImageFormatFromBuffer

Start Chat