Starts the resizing process.
#include "l_bitmap.h"
L_LTKRN_API L_INT L_StartResizeBitmap(pBitmap, nNewWidth, nNewHeight, nNewBits, pPalette, nColors, uFlags, pfnCallback, pCallbackData, ppResizeData)
Pointer to a bitmap handle.
New width of the image.
New height of the image.
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.
Pointer to the palette to dither to if nNewBits
<= 8. Pass NULL to dither to the fixed palette or if no palette is required.
The number of entries in pPalette
. This value is only valid if pPalette is not NULL.
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. |
RES_ORDERRGB565 | [0x00004000] RGB 565 byte order. |
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. |
RES_USELUTAFTERRESIZE | [0x00001000] Internal flag. |
RES_IGNORELUT | [0x00002000] Internal flag. |
RES_LOWHIGHBITVALID | [0x00000002] Internal use only. |
Pointer to an optional callback that is used to get the rows from pBitmap
. Pass NULL to have LEADTOOLS call L_GetBitmapRow directly.
Optional parameter to be passed to pfnCallback
.
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.
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
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
.
Win32, x64, Linux.
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;
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;
}
L_AccessBitmap(&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, Bitmap.BytesPerLine);
}
L_ReleaseBitmap(&Bitmap);
L_StopResizeBitmap(pResizeData);
if(nRet == SUCCESS)
{
if(pBitmap->Flags.Allocated)
L_FreeBitmap(pBitmap);
L_CopyBitmap(pBitmap, &Bitmap, sizeof(BITMAPHANDLE));
}
L_FreeBitmap(&Bitmap);
return nRet;
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document