Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Wednesday, March 21, 2012 11:23:56 PM(UTC)
fildomen

Groups: Registered
Posts: 1


Hi,
I'm trying to binarize a bitmap with L_AutoBinarizeBitmap and call L_BorderRemoveBitmap after that, the problem is that i get a ERROR_BITPERPIXEL error on the BorderRemove method. Here is my code:

L_INT Doc2AddPageExample(L_HDOC2 hDoc,L_TCHAR* pszFileName)
{
L_INT nRet;
BITMAPHANDLE Bitmap;
L_INT nPageCount = 0;
L_TCHAR szBuffer[100];

memset(szBuffer, 0, sizeof(szBuffer));

nRet = L_InitBitmap(&Bitmap, sizeof(BITMAPHANDLE), 0, 0,0);
if(nRet != SUCCESS)
return nRet;

nRet = L_LoadBitmap(pszFileName, &Bitmap, sizeof(BITMAPHANDLE),0, ORDER_BGRORGRAY, NULL, NULL);
if (nRet != SUCCESS)
return nRet;

nRet = L_AutoBinarizeBitmap( &Bitmap, 0, AUTO_BINARIZE_PRE_BG_ELIMINATION | AUTO_BINARIZE_THRESHOLD_AUTO);
if (nRet != SUCCESS)
return nRet;

nRet = BorderRemoveBitmapExample( &Bitmap);
if (nRet != SUCCESS)
return nRet;

nRet = L_Doc2AddPage(hDoc, &Bitmap, 0);
if (nRet != SUCCESS)
return nRet;

nRet = L_Doc2GetPageCount (hDoc, &nPageCount);
return SUCCESS;
}

L_INT BorderRemoveBitmapExample(pBITMAPHANDLE pBitmap)
{
L_INT32 nRet;
BORDERREMOVE br;
BITMAPHANDLE RegionBitmap;

memset(&RegionBitmap, 0, sizeof(BITMAPHANDLE));

//Create a NULL region
br.uStructSize = sizeof(BORDERREMOVE);
br.iBorderPercent = 20;
br.iVariance = 2;
br.iWhiteNoiseLength = 5;
br.uBorderToRemove = BORDER_TOP | BORDER_BOTTOM | BORDER_LEFT | BORDER_RIGHT;
br.uFlags = BORDER_USE_VARIANCE;
br.pBitmapRegion = &RegionBitmap;
br.uBitmapStructSize = sizeof(BITMAPHANDLE);

nRet = L_BorderRemoveBitmap( pBitmap,&br,NULL,NULL,0);

if (nRet == SUCCESS)
{
RECT rectRgn;
HRGN hRgnAll;
GetRgnBox(hRgnAll, &rectRgn);
if (!IsRectEmpty(&rectRgn))
{
nRet = L_SetBitmapRgnHandle(pBitmap, NULL, hRgnAll, L_RGN_SET);
if(nRet != SUCCESS)
return nRet;
DeleteObject(hRgnAll);
}
}
else
{
return nRet;
}

return nRet;
}

Can someone help me figure out how to make it work ?

Thank you,

Yassine
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Thursday, March 22, 2012 6:35:17 AM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,326

Was thanked: 1 time(s) in 1 post(s)

To resolve the problem, you need to change the bitmap's bits-per-pixel to 1-bit after calling the L_AutoBinarizeBitmap() function. You can do this by using the L_ColorResBitmap() function.

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.066 seconds.