Herd Software Development
DaVinci Graphics Library
Provided since 16 bit Windows has no internal functions for DIB rotation. This function is also available in the 32 bit version of Leonardo for compatibility.
HDIB FAR PASCAL RotateDIB(
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.
Angle Integer value specifying the counterclockwise angle of rotation in tenths of a degree, e.g. 900 for a quarter turn to the right. The angle of rotation is defined in mathematical sense of rotation: Positive values rotate to the left.
clBkColor Background color for the new areas generated by the rotation process which are not filled by the source DIB.
If the specified angle of rotation is <> 90, 180 or 270 degrees, this function produces a bitmap of a larger size than the original, since the bounding rectangle rotates on an axis centered on the center of the image. (See remarks below.) clBkColor specifies the color of the new display elements (0xFFFFFF for white).
Returns a handle to the newly-generated DIB, or NULL if the function did not succeed. The handle must be released by the application using GlobalFree. The returned DIB has the same color depth and palette as the source DIB.
This function is based on the Leonardo function TransformDIB, which is more flexible and provides callback notification for use in progress bars and other indicators.
The example below shows how the surface area required by a DIB will increase when rotation angle values not divisible by 900 are used. Maximum increase in required surface area occur when Angle modulus 900 = 450.
|Original figure:||Rotated figure (angle of rotation: 30 degrees; background color: Red)|
The color of the red pixels in the example is defined by the clBkColor parameter, and the two figures accurately represent the surface area requirements of both images.
RotateDIB 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.
DaVinci is optimized for increased output speed in the following special cases:
RGB (Windows API macro)
COLORREF (and/or OWL/Object Pascal TColorRef type)