L_ResizeBitmap
#include "l_bitmap.h"
L_INT EXT_FUNCTION L_ResizeBitmap(pSrcBitmap, pDstBitmap, uFlags)
pBITMAPHANDLE pSrcBitmap; |
/* pointer to the source bitmap handle */ |
pBITMAPHANDLE pDstBitmap; |
/* pointer to the destination bitmap handle */ |
L_UINT uFlags; |
/* flags that determine resizing options */ |
Resizes the image from an existing bitmap, and puts the resized image into a destination bitmap, leaving the original bitmap intact.
Parameter |
Description |
|
pSrcBitmap |
Pointer to the bitmap handle referencing the source bitmap. |
|
pDstBitmap |
Pointer to the bitmap handle referencing the destination bitmap to contain the new resized image. |
|
uFlags |
Flags that determine resizing options. Possible values are: |
|
|
Value |
Meaning |
|
SIZE_NORMAL |
[0x0000] Resize normally. |
|
SIZE_FAVORBLACK |
[0x0001] (Document/Medical only) Preserve black objects when making the image smaller. This option affects only 1-bit, black-and-white images, where it prevents the disappearance of thin lines. You can use a bitwise OR ( | ) to combine this flag with another one. For example, SIZE_RESAMPLE | SIZE_FAVORBLACK causes color images to be resampled, but applies the favor-black option to 1-bit, black-and-white images. |
|
SIZE_RESAMPLE |
[0x0002] Use linear interpolation and averaging to produce a higher-quality image. |
|
SIZE_BICUBIC |
[0x0004] Use bicubic interpolation and averaging to produce a higher quality image. This is slower than SIZE_RESAMPLE. |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
You are responsible for allocating enough storage for the destination bitmap. If only one copy is desired, use the L_SizeBitmap function instead of this one.
If you are working with an 8-bit or less image, before calling this function, you must ensure that both bitmap handles refer to the same palette. To do so, you can use the L_CopyBitmapPalette function to duplicate the palette as follows:
L_CopyBitmapPalette(&DestinationBitmap, &SourceBitmap.hPalette);
To update a status bar or detect a user interrupt during execution of this function, refer to L_SetStatusCallback.
Required DLLs and Libraries
LTKRN For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application. |
Platforms
Windows 95 / 98 / Me, Windows 2000 / XP, Windows CE.
See Also
Example
For complete sample code, refer to the FEATURE1 example.
/* This example loads a temporary bitmap, and uses L_ResizeBitmap to create a new
bitmap half the size of the original. The example also demonstrates low-level functions for
initializing and allocating a bitmap. The same tasks can be done more efficiently with
high-level functions. */
/* Note that the result is not very good because we resize a dithered image. */
BITMAPHANDLE LeadBitmap; /* Bitmap handle for the final image */
BITMAPHANDLE TmpBitmap; /* Bitmap handle for the initial image */
L_INT NewWidth, NewHeight; /* Resize dimensions */
/* Load the temporary bitmap at 8 bits per pixel so that we can demonstrate
how to handle its palette. */
L_LoadBitmap (TEXT("IMAGE3.CMP"), &TmpBitmap, sizeof(BITMAPHANDLE), 8, ORDER_BGR, NULL, NULL);
/* Define the dimensions for resizing */
NewWidth = TmpBitmap.Width / 2;
NewHeight = TmpBitmap.Height / 2;
/* Initialize the new bitmap handle. */
L_InitBitmap( &LeadBitmap, sizeof(BITMAPHANDLE), NewWidth, NewHeight, TmpBitmap.BitsPerPixel );
/* Allocate the storage to hold the image data. */
L_AllocateBitmap( &LeadBitmap, TYPE_CONV );
/* Duplicate the palette */
L_CopyBitmapPalette(&LeadBitmap, &TmpBitmap);
/* Set other useful values in the bitmap handle */
LeadBitmap.ViewPerspective = TmpBitmap.ViewPerspective;
LeadBitmap.XResolution = TmpBitmap.XResolution;
LeadBitmap.YResolution = TmpBitmap.YResolution;
LeadBitmap.Order = TmpBitmap.Order;
/* Resize TmpBitmap to create LeadBitmap */
L_SaveBitmap(TEXT("d:\\temp\\RESIZE.BMP"), &LeadBitmap, FILE_BMP, 0, 0, NULL);
L_ResizeBitmap (&TmpBitmap, &LeadBitmap, SIZE_NORMAL);
/* Free the temporary bitmap */
L_FreeBitmap(&TmpBitmap);
/* Free the resized bitmap */
L_FreeBitmap(&LeadBitmap);