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 : Tuesday, September 19, 2017 11:25:17 PM(UTC)

tksong  
tksong

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.
 

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 : Friday, September 22, 2017 8:04:28 AM(UTC)

Aaron  
Aaron

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.html

You 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.

LEAD Logo
thanks 2 users thanked Aaron for this useful post.
tksong on 10/10/2017(UTC), redminote on 4/12/2018(UTC)
 
#3 Posted : Monday, October 9, 2017 10:19:03 PM(UTC)

tksong  
tksong

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.

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