| Herd Software Development
|=
DaVinci Graphics Library
|==
DaVinci Documentation Home Search Order


Leonardo: The StretchDIB function

The StretchDIB function in Leonardo creates a DIB consisting of a rescaled copy of a section of another DIB.

Windows' API provides StretchDIBits and StretchBlt for stretching, shrinking, cutting and mirroring images, but API functions act directly on a device context. These functions will fail in 16 bit applications used on 16 bit Windows operating systems when large zoom factors are used.

HDIB FAR PASCAL StretchDIB(
HDIB hDIB,
int cxDest,
int cyDest,
LPRECT rc);

hDIB Handle of a source DIB at 1, 4, 8 or 24 bits of color depth.

The handle of the source DIB remains valid after this operation.

cxDest Width of the new DIB in pixels, must be >0.

cyDest Height of the new DIB in pixels; must be >0.

rc Pointer to a RECT structure specifying the bounding rectangle of the area of the source DIB to be copied. This value can be NULL if the input DIB should be copied as a whole.

To create a mirror image of the original, specify the bounding rectangle as left>right and bottom>top.

Returns

Returns the handle of the newly created DIB, or NULL if the function was unsuccessful. The handle must be released by the application with the function GlobalFree.

The returned DIB has the same color resolution and color palette as the source DIB.

Remarks

This function is based on Leonardo's TransformDIB function. TransformDIB offers more flexibility and permits the use of callback procedures for such things as progress bars.

The ScaleToGray function performs the same processing but produces higher resolution when resizing images to smaller dimensions.

Memory requirements

StretchDIB requires little memory for its own purposes. Memory requirements for the function are determined primarily by the sizes of the input and output DIBs.

DIBs at 1 bit color depth can be processed directly so that main memory requirements are low. Approximately 500KB of memory is required for the two DIBs needed in the rotation of a full-page monochrome fax document image.

Computation speed

The computation speed of this function is determined almost exclusively by the size of the destination bitmap. The output of a large image in a small window can therefore be done quite rapidly.

Remarks

DIB downscaling operations performed using ScaleToGray will often result in higher output quality.

This function is based on StretchDIB2DIBBlt

Optimization

DaVinci Professional contains optimized routines for enhanced performance in the following special cases: