#include "l_bitmap.h"
L_LTKRN_API L_INT L_ChangeBitmapHeight(pBitmap, nHeight)
pBITMAPHANDLE pBitmap; |
pointer to the bitmap handle |
L_INT nHeight; |
new height in pixels |
Increases or decreases the allocated height of a bitmap. You can use this function in a callback routine to adjust the allocation when loading an image of unknown height.
Parameter |
Description |
pBitmap |
Pointer to the bitmap handle referencing the bitmap to be adjusted. |
nHeight |
New height in pixels. |
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
This function updates the fields in the bitmap handle to reflect the change.
Required DLLs and Libraries
For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application. |
Win32, x64, Linux.
Functions: |
|
Topics: |
|
|
|
|
|
|
This FILEREADCALLBACK example uses L_ChangeBitmapHeight to ensure that the final bitmap height is the same as the total number of loaded lines. This can be especially useful when you are loading fax files and you don’t know how many lines are in the file. Normally, you know the width of the raw fax files but not the height. So you can start by allocating a small bitmap and increase its height while decoding the file.
#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName
L_UINT TotalLines; /* Total number of loaded lines */
L_INT EXT_CALLBACK LoadImageCB(pFILEINFO pFileInfo,
pBITMAPHANDLE pBitmap,
L_UCHAR* pBuffer,
L_UINT uFlags,
L_INT nRow,
L_INT nLines,
L_VOID* pUserData )
{
UNREFERENCED_PARAMETER(pFileInfo);
UNREFERENCED_PARAMETER(pBuffer);
UNREFERENCED_PARAMETER(uFlags);
UNREFERENCED_PARAMETER(nRow);
UNREFERENCED_PARAMETER(pBitmap);
BITMAPHANDLE *pMyBitmap = (BITMAPHANDLE*)pUserData;
/* Increment the current row by the number of lines in the buffer */
TotalLines += nLines;
/* Set the bitmap height to the total number of lines */
L_AccessBitmap(pMyBitmap);
if( TotalLines > (L_UINT)pMyBitmap->Height )
{
L_ReleaseBitmap(pMyBitmap);
L_ChangeBitmapHeight(pMyBitmap, TotalLines );
L_AccessBitmap(pMyBitmap);
}
L_PutBitmapRow(pMyBitmap, pBuffer, nRow, pMyBitmap->BytesPerLine * nLines);
L_ReleaseBitmap(pMyBitmap);
return( SUCCESS );
}
L_INT ChangeBitmapHeightExample(L_VOID)
{
L_INT nRet;
BITMAPHANDLE LeadBitmap;
BITMAPHANDLE DummyBitmap;
FILEINFO FileInfo;
memset(&FileInfo, 0, sizeof(FILEINFO));
nRet = L_FileInfo(MAKE_IMAGE_PATH(TEXT("OCR1.TIF")), &FileInfo, sizeof(FILEINFO), 0, NULL);
if(nRet != SUCCESS)
return nRet;
/* init and allocate the bitmap, to be 1/2 the actual size of the image */
L_InitBitmap(&LeadBitmap, sizeof(BITMAPHANDLE), FileInfo.Width, FileInfo.Height / 2, FileInfo.BitsPerPixel);
L_AllocateBitmap(&LeadBitmap, TYPE_CONV);
nRet = L_LoadFile(MAKE_IMAGE_PATH(TEXT("OCR1.TIF")), &DummyBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, 0, LoadImageCB, (L_VOID*)&LeadBitmap, NULL, NULL);
if(nRet != SUCCESS)
return nRet;
L_FreeBitmap(&LeadBitmap);
L_FreeBitmap(&DummyBitmap);
return nRet;
}
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.