Available in LEADTOOLS Imaging Pro, Vector, Document, and Medical Imaging toolkits. |
L_StartResizeBitmap
#include "l_bitmap.h"
L_LTKRN_API L_INT L_StartResizeBitmap(pBitmap, nNewWidth, nNewHeight, nNewBits, pPalette, nColors, uFlags, pfnCallback, pCallbackData, ppResizeData)
pBITMAPHANDLE pBitmap; |
/* handle to a bitmap */ |
L_INT nNewWidth; |
/* new width of the image */ |
L_INT nNewHeight; |
/* new height of the image */ |
L_INT nNewBits; |
/* new bits per pixel for the image */ |
L_RGBQUAD* pPalette; |
/* palette */ |
L_INT nColors; |
/* number of entries in pPalette */ |
L_UINT uFlags; |
/* resizing flags */ |
RESIZECALLBACK pfnCallback; |
/* optional callback function */ |
L_VOID *pCallbackData; |
/* optional parameter */ |
L_VOID ** ppResizeData; |
/* address of a pointer for resize data */ |
Starts the resizing process.
Parameter |
Description |
|
pBitmap |
Pointer to a bitmap handle. |
|
nNewWidth |
New width of the image. |
|
nNewHeight |
New height of the image. |
|
nNewBits |
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 nNewBits<= 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 Document and Medical Imaging toolkits. |
|
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 to have 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
Win32, x64, Mobile.
See Also
Functions: |
L_GetResizedRowCol, L_StopResizeBitmap, L_SizeBitmap, L_Resize, L_StopResize, L_DlgResize |
Topics: |
Example
L_INT StartResizeBitmapExample(pBITMAPHANDLE pBitmap,L_INT nWidth,L_INT nHeight) { L_VOID* pResizeData; L_INT nRet; L_UCHAR* 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 *)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_StopResizeBitmap(pResizeData); if(nRet == SUCCESS) { if(pBitmap->Flags.Allocated) L_FreeBitmap(pBitmap); L_CopyBitmap(pBitmap, &Bitmap, sizeof(BITMAPHANDLE)); } L_FreeBitmap(&Bitmap); return nRet; }