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


Leonardo: The StretchDIBBlt function

Copies the color data for a rectangle of pixels in the source DIB to a specified rectangular area in the target DIB. If the destination rectangle has different dimensions from the rectangle selected from the source image, this function automatically rescales the pixel data to fit the target rectangle. This is essentially a "wrapper" for Windows' StretchDIBits function.

BOOL API StretchDIBBlt (
HDC hDC,
int xDst,
int yDst,
int dxDst,
int dyDst,
HDIB hdib,
int xSrc,
int ySrc,
int dxSrc,
int dySrc,
LONG rop);

Parameter Type Description

hDC HDC Specifies the device context for the window, memory bitmap or metafile used as the target for the operation.

xDst int Specifies the left x coordinate of the upper left corner of the target rectangle in logical units.

yDst int Specifies the top y coordinate of the upper left corner of the destination rectangle in logical units.

dxDst int Specifies the width of the target rectangle in logical units.

dyDst int Specifies the height of the target rectangle in logical units.

hDIB HDIB Handle of the source DIB from which data will be copied (e.g. a handle returned by ipImportInd or LoadDIBFromFile).

xSrc int Specifies the left x coordinate of the rectangle in the source DIB in pixels.

ySrc int Specifies the lower y coordinate, in pixels, of the rectangle in the source DIB in pixels.

dxSrc int Specifies the width of the rectangle in the source DIB in pixels.

dySrc int Specifies the height of the rectangle in the source DIB in pixels.

rop LONG Specifies how the source pixels, the destination device context's current brush, and the destination pixels are to be combined to form the new image. Usually specified as SRCCOPY.

Returns

The returned value is the number of copied scan lines.

Remarks

StretchDIBits uses the stretch mode of the target device context as set by SetStretchBltMode to determine how to stretch or scale down the bitmap. When rescaling DIBs of biBitCount <=8 to smaller sizes, the default often produces ugly stripes on the target image.

The origin of the destination depends on the current mapping mode of the device context. Further information on mapping modes is available in the API documentation for SetMapMode.

StretchDIBBlt creates a mirror image of the bitmap if the signs of the parameters dxSrc and dxDst and/or dySrc and dyDst differ from each other.

This function also accepts images in the Microsoft OS/2 Presentation Manager 1.1/1.2 device-independent bitmap format if the lpBitsInfo parameter specifies a BITMAPCOREINFO data structure.

If the input DIB has a greater color depth than the output device context, image quality may be lost during display, especially if the number of colors used by the target device is fewer than the number of colors used by the source image. In cases where the copy operation requires reduction of color depth, each pixel's color is calculated based on the nearest available color in the target device's palette. Printer output can usually be dithered by the printer driver. In Win32 the output can be dithered by a call to SetStretchBltMode.

Color depth reduction performed by this function is based on the color palette selected by the application with SelectPalette. If no palette is specified by the application, only the standard Windows 20 system colors will be used on the target device.

Display of RGB DIBs with color depth >= 16 bits may be very slow on palette-based output devices, but this depends primarily on the capabilities of the video driver. If necessary, screen output can be accelerated by using DitherTo8.

Using this function in Win16 environments

StretchDIBBlt and/or StretchBlt are defective in Windows 3.1, resulting in the function failing with large scaling factors. Higher reliability over a wider range of potential applications can be achieved using Leonardo's StretchDIB and/or StretchDIB2DIBBlt. functions.