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 : Thursday, August 20, 2009 10:25:24 AM(UTC)

grhind  
grhind

Groups: Registered
Posts: 19


I am having trouble getting the crop command to work after the image has been zoomed.

i'm using this for my zooming
_viewer.ScaleFactor = dblScaleFactor (what ever number between 0 and 2)

here is my crop code
Private Sub _viewer_InteractiveRegionRectangle(ByVal sender As Object, ByVal e As Leadtools.WinForms.RasterViewerRectangleEventArgs) Handles _viewer.InteractiveRegionRectangle
If e.Status = RasterViewerInteractiveStatus.End Then
Select Case (_action)
Case ActionType.Crop
Dim rc As Rectangle = e.Rectangle
Dim scaleFactor As Double = _viewer.ScaleFactor
scaleFactor = 2 - scaleFactor

rc = New Rectangle(e.Rectangle.X * scaleFactor, e.Rectangle.Y * scaleFactor, e.Rectangle.Width * scaleFactor, e.Rectangle.Height * scaleFactor)
_viewer.Image.MakeRegionEmpty()
Dim crop As Leadtools.ImageProcessing.CropCommand = New Leadtools.ImageProcessing.CropCommand(rc)

crop.Run(_viewer.Image)

'set cursor back to default
_action = ActionType.None
_viewer.InteractiveMode = RasterViewerInteractiveMode.None
_viewer.Cursor = Cursors.Default
End Select
End If
End Sub
 

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, August 20, 2009 10:27:52 AM(UTC)

grhind  
grhind

Groups: Registered
Posts: 19


sorry forgot to mention what my problem is... when there is not zooming the crop works fine... when there is a zoom in or out the area that i want cropped isn't the area that gets cropped.

I had a similar problem with rotation but i found there was difference between using RotateCommand and using RotateViewPerspective... perhaps i have a similar problem?
 
#3 Posted : Thursday, August 20, 2009 12:10:18 PM(UTC)

GregR  
GregR

Groups: Registered, Tech Support, Administrators
Posts: 764


Most likely, it's just an error in the math.  Either way, there's a much easier way to accomplish the same thing.  Instead of handling the InteractiveRegionRectangle event, just handle the InteractiveModeEnded event and do something like this:


Private Sub RasterImageViewer1_InteractiveModeEnded(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RasterImageViewer1.InteractiveModeEnded
    If RasterImageViewer1.InteractiveMode = RasterViewerInteractiveMode.Region And RasterImageViewer1.InteractiveRegionType = RasterViewerInteractiveRegionType.Rectangle Then
        Dim crop As Leadtools.ImageProcessing.CropCommand = New Leadtools.ImageProcessing.CropCommand(RasterImageViewer1.Image.GetRegionBounds(Nothing))
        RasterImageViewer1.Image.MakeRegionEmpty()
        crop.Run(RasterImageViewer1.Image)
    End If
End Sub

 
#4 Posted : Friday, August 21, 2009 3:34:16 AM(UTC)

grhind  
grhind

Groups: Registered
Posts: 19


That works... thank you very much!
 
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.065 seconds.