L_StartResizeBitmap
#include "l_bitmap.h"
L_INT EXT_FUNCTION L_StartResizeBitmap(pBitmap, nDestWidth, nDestHeight, nDestBits, pPalette, nColors, uFlags, pfnCallback, pCallbackData, ppResizeData)
pBITMAPHANDLE pBitmap; |
/* handle to a bitmap */ |
L_INT nDestWidth; |
/* new width of the image */ |
L_INT nDestHeight; |
/* new height of the image */ |
L_INT nDestBits; |
/* new bits per pixel for the image */ |
LPRGBQUAD pPalette; |
/* palette */ |
L_INT nColors; |
/* number of entries in pPalette */ |
L_UINT32 uFlags; |
/* resizing flags */ |
RESIZECALLBACK pfnCallback; |
/* optional callback function */ |
/* optional parameter */ | |
/* address of a pointer for resize data */ |
Starts the resizing process.
Parameter |
Description |
|
PBitmap |
Pointer to a bitmap handle. |
|
NDestWidth |
New width of the image. |
|
NDestHeight |
New height of the image. |
|
NDestBits |
Output bits per pixel. Use 0 for 8-bit grayscale. Possible values are: 0, 1, 2, 3, 4, 5, 6, 7, 8, 12, 16, 24, 32, 48 and 64., |
|
PPalette |
Pointer to the palette to dither to if nDestBits <= 8. Pass NULL to dither to the fixed palette or if no palette is required |
|
NColors |
The number of entries in pPalette. This value is only valid if pPalette is not NULL |
|
UFlags |
Flags that indicate the color order of the image, the type of resizing and the type of dithering. Flags from the different categories can be combined, but two flags from the same category can not be combined. Possible values are: |
|
|
Value |
Meaning |
|
ColorRes flags |
|
|
RES_ORDERRGB |
[0x00000000] RGB color. |
|
RES_ORDERBGR |
[0x00000004] BGR color order. |
|
RES_ORDERGRAY |
[0x00000080] 12 or 16-bit grayscale. 12 and 16-bit grayscale images are only supported in the Document/Medical Imaging editions. |
|
RES_ORDERROMM |
[0x00000800] ROMM color order. ROMM only supports 24 and 48-bit images. |
|
Resize flags |
|
|
RES_NORMAL |
[0x00000000] Normal resizing. |
|
RES_RESAMPLE |
[0x00000010] Linear interpolation resizing – slower than RES_NORMAL. |
|
RES_BICUBIC |
[0x00000020] Bicubic interpolation resizing – slower than RES_RESAMPLE. |
|
Dithering flags |
|
|
RES_NODITHERING |
[0x00000000] No Dithering |
|
RES_FLOYDSTEINDITHERING |
[0x00010000] Floyd Stein Dithering |
|
RES_STUCKIDITHERING |
[0x00020000] Stucki Dithering |
|
RES_BURKESDITHERING |
[0x00030000] Burkes Dithering |
|
RES_SIERRADITHERING |
[0x00040000] Sierra Dithering |
|
RES_STEVENSONARCEDITHERING |
[0x00050000] Stevenson Arce Dithering |
|
RES_JARVISDITHERING |
[0x00060000] Jarvis Dithering |
|
RES_ORDEREDDITHERING |
[0x00070000] Ordered Dithering |
|
RES_CLUSTEREDDITHERING |
[0x00080000] Clustered Dithering |
|
RES_DITHERINGOPTIONS |
[0x00FF0000] Mask to find dither option |
pfnCallback |
Pointer to an optional callback that is used to get the rows from pBitmap. Pass NULL tohave LEADTOOLS call L_GetBitmapRow directly. |
|
pCallbackData |
Optional parameter to be passed to pfnCallback. |
|
ppResizeData |
Pointer to a variable that will be updated with information needed to perform the resize. You need to pass this information to subsequent calls to L_GetResizedRowCol and L_StopResizeBitmap. |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
The dithering flags are used when dithering is needed to produce the output bits per pixel. The interpolation usually requires that the input data be converted to 24-bit or 48-bit and then back to the desired bits per pixel. So some dithering might be required if the output bits/pixel are <= 8.
L_StartResizeBitmap starts the resizing process. This will be followed by calls to L_GetResizedRowCol to retrieve the resized data and by a call to L_StopResizeBitmap, to free the memory allocated in ppResizeData.
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
Functions: |
L_GetResizedRowCol, L_StopResizeBitmap, L_SizeBitmap, L_Resize, L_StopResize, L_DlgResize |
Topics: |
Example
// for GlobalAllocPtr
#include <windowsx.h>
L_INT MySizeBitmap(pBITMAPHANDLE pBitmap, L_INT nWidth, L_INT nHeight)
{
L_VOID L_FAR*pResizeData;
L_INT nRet;
L_UCHAR L_FAR*pBuffer;
BITMAPHANDLE Bitmap;
L_INT nRow=0;
L_INT nCol=0;
L_UINT uBytes;
nRet = L_StartResizeBitmap (pBitmap, nWidth, nHeight, 24,
NULL, // no palette
0,
RES_BICUBIC|RES_ORDERBGR, // bicubic interpolation, BGR order
NULL, // no callback
NULL, // no user data
&pResizeData);
if(nRet != SUCCESS)
return nRet;
nRet = L_CreateBitmap(&Bitmap, sizeof(BITMAPHANDLE), TYPE_CONV, nWidth, nHeight, 24, ORDER_BGR, NULL,
pBitmap->ViewPerspective, NULL, 0);
if(nRet != SUCCESS)
{
L_StopResizeBitmap(pResizeData);
return nRet;
}
pBuffer = (L_UCHAR L_FAR*)GlobalAllocPtr(GMEM_MOVEABLE, Bitmap.BytesPerLine);
if(!pBuffer)
{
L_FreeBitmap(&Bitmap);
L_StopResizeBitmap(pResizeData);
return nRet;
}
uBytes = BITMAPWIDTH(&Bitmap);
// get the rows for the resized image, one by one
for(nRow = 0; nRow < Bitmap.Height; nRow++)
{
nRet = L_GetResizedRowCol(pResizeData, pBuffer, nRow, 0, Bitmap.BytesPerLine);
if(nRet != SUCCESS)
break;
L_PutBitmapRowCol(&Bitmap, pBuffer, nRow, nCol, uBytes);
}
L_StopResize(pResizeData);
if(nRet == SUCCESS)
{
// free the old bitmap
L_FreeBitmap(pBitmap);
// put the new bitmap in pBitmap
*pBitmap = Bitmap;
}
return nRet;
}