This topic and its replies were posted before the current version of LEADTOOLS was released and may no longer be applicable.
#1
Posted
:
Monday, August 23, 2010 11:30:13 AM(UTC)
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.
#2
Posted
:
Tuesday, August 24, 2010 3:20:38 AM(UTC)
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)
Groups: Registered
Posts: 8
#4
Posted
:
Wednesday, August 25, 2010 3:57:00 AM(UTC)
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.