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 : Monday, August 23, 2010 11:30:13 AM(UTC)
TrueGeek

Groups: Registered
Posts: 8


I've having trouble cropping an image. I'm using v17.

I have a RasterImageViewer (named CurrentImage) with InteractiveMode="UserRectangle"

During the event InteractiveUserRectangle I'm saving e.Bounds to a Rectangle named _userRectangle while e.Status == InteractiveModeStatus.Working. I'm following the sample code from the Barcode example (my app is WPF) and showing a rectangle in a canvas when InteractiveMode ends.

I've tried to crop a few ways but none are working.

1)
            Leadtools.LeadRect rc = CurrentImage.Image.GetRegionBounds(null);
            CurrentImage.Image.MakeRegionEmpty();
            Leadtools.ImageProcessing.CropCommand crop = new Leadtools.ImageProcessing.CropCommand(rc);
            crop.Run(CurrentImage.Image);

This doesn't do anything. The image is unchanged. I've also noticed that rc.Height and rc.Width are 0.

2)
            CurrentImage.ZoomToRectangle(_userRectangle);
            Leadtools.LeadRect rect = CurrentImage.Image.GetRegionBounds(null);
            CurrentImage.Image.MakeRegionEmpty();
           
            Leadtools.ImageProcessing.CropCommand cmd = new Leadtools.ImageProcessing.CropCommand(rect);
            cmd.Run(CurrentImage.Image);

            _userRectangle = Rect.Empty;

This zooms into an area somewhat representing the area I outlined in my rectangle, but it does not crop.

3)
            Leadtools.ImageProcessing.CropCommand cmdCrop = new Leadtools.ImageProcessing.CropCommand();

            int Top = int.Parse(_userRectangle.Top.ToString());
            int Left = int.Parse(_userRectangle.Left.ToString());
            int Width = int.Parse(_userRectangle.Width.ToString());
            int Height = int.Parse(_userRectangle.Height.ToString());

            cmdCrop.Rectangle = new Leadtools.LeadRect(
                Top,
                Left,
                Width,
                Height);

            cmdCrop.Run(CurrentImage.Image);

This also does nothing.

Can you show me the correct syntax to crop a photo in v17 after selecting a region? I also need RedEye, but I imagine the process will be similar.

Thanks.





 

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 : Tuesday, August 24, 2010 3:20:38 AM(UTC)

Adam Boulad  
Guest

Groups: Guests
Posts: 3,022

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

Can you create a small sample project (not your full application) that uses the first approach for example and send it to me in a ZIP or RAR file?
You can either post it here or send it to support@leadtools.com and mention this post.
When attaching to the forums, do not use the "Preview" feature.
 
#3 Posted : Tuesday, August 24, 2010 7:18:22 AM(UTC)
TrueGeek

Groups: Registered
Posts: 8


Sure, here you go.
File Attachment(s):
croptest.zip (36kb) downloaded 73 time(s).
 
#4 Posted : Wednesday, August 25, 2010 3:57:00 AM(UTC)

Adam Boulad  
Guest

Groups: Guests
Posts: 3,022

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

In your project, in the btnCrop1_Click function, you swapped the Top and Left variables.
The function should be:
cmdCrop.Rectangle = new Leadtools.LeadRect(Left, Top, Width, Height);

Not:
//cmdCrop.Rectangle = new Leadtools.LeadRect(
//    Top,
//    Left,
//    Width,
//    Height);
Please try this modification and you can use the crop method 1 in your project.
 
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.138 seconds.