#1
Posted
:
Tuesday, September 19, 2017 11:25:17 PM(UTC)
Groups: Registered
Posts: 10
Thanks: 1 times
in MFC, LEADTOOL v19
While implementing Rotate using the RotateBitmapPerspective function of LImageViewerCell,
I found that it is possible to rotate only at certain angles.
To rotate at other angles,
For testing, we added the Test menu to the ImageViewer example and implemented it as shown below.
//Test menu Event Handler
void CImageViewerView::OnTestRotate()
{
// TODO: Add your command handler code here
BITMAPHANDLE Bitmap;
pBITMAPHANDLE pBitmap;
LBitmap tmpBitmap;
LImageViewerCell* pCell = m_ImageViewer.GetCellHandle(0, 0);
L_INT nRet = pCell->GetBitmapHandle(0, &Bitmap, 0);
tmpBitmap.SetHandle(&Bitmap);
tmpBitmap.Rotate(15);
pBitmap = tmpBitmap.GetHandle();
nRet = pCell->SetBitmapHandle(0, pBitmap, FALSE, 0);
}
However, after the image rotates for the first time only, the program terminates abnormally.
It seems to be a problem with GetBitmapHandle and SetBitmapHandle,
I want to know the exact usage.
#2
Posted
:
Friday, September 22, 2017 8:04:28 AM(UTC)
Groups: Registered, Tech Support, Administrators
Posts: 71
Was thanked: 4 time(s) in 3 post(s)
Hi,
The issue here is your code is not detaching that handle from the LBitmap object after you set the bitmap back into the cell. So, the second time through the function, the handle is still there, hence causing an Access Violation that is crashing the application. You can easily fix this by simply detaching the handle from the object once you a finished with your processing:
https://www.leadtools.co...itmapbase-sethandle.htmlYou could also update your code slightly to be cleaner and not have to use a pBITMAPHANDLE. You can reference the OnEffectsFlip function for exactly how the image processing commands are currently handled in the demo. Here is the updated/cleaned code that will rotate a LBitmap in the cell as many times as you need without crashing the application:
Code:
BITMAPHANDLE Bitmap;
LBitmap tmpBitmap;
LImageViewerCell* pCell = m_ImageViewer.GetCellHandle(0, 0);
pCell->GetBitmapHandle(0, &Bitmap, 0);
tmpBitmap.SetHandle(&Bitmap, TRUE);
tmpBitmap.Rotate(15);
pCell->SetBitmapHandle(0, tmpBitmap.GetHandle(), TRUE, 0);
tmpBitmap.SetHandle(NULL, FALSE);
As you can see in the code snippet above, you can set the bitmap handle to NULL once you are finished with your manipulation which will detach the handle from the object.
If you have any further questions or concerns please let us know.
Aaron Brasington
Developer Support Engineer
LEAD Technologies, Inc.
2 users thanked Aaron for this useful post.
#3
Posted
:
Monday, October 9, 2017 10:19:03 PM(UTC)
Groups: Registered
Posts: 10
Thanks: 1 times
problem solved. thank you a lot
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.