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, November 11, 2010 6:04:49 AM(UTC)

Whitey  
Whitey

Groups: Registered
Posts: 7


I've created an WPF image editing program that allows the user to copy crop areas (polygons, rects & ellipses) into floaters, transform the region (scale, translate, rotate), and paste it back into the original photo.  Now, I'm trying to add some features that allow the pasted region to look more like it was part of the original photo.

I'm adding an ellipse (circular) to the canvas that can be scaled using a slider.  It can be moved around the canvas by left clicking it; however, when I right click the ellipse I want the area under the ellipse to one of three things as it's being dragged  (mode determined by pressing one of three buttons): Blur, Paint, Opacity.

Blur:  The pixellated edges of a pasted region are blurred, probably by averaging the underlying pixels, but the type of blur is of less importance than the final effect.

Paint:  Copy the set of pixels under the ellipse when it the mouse is down, and replace the original pixels on the canvas with the copied ones.

Opacity:  Change the opacity of the underlying pixels based upon a slider value.

Any suggestions would help.  I've got the 16.5 package.  I've seen examples of how to blur a whole package, but I'm having trouble doing it interactively with a small, rounded area.

Thanks for any help,
Whitey
 

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 : Sunday, November 14, 2010 5:57:27 AM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,326

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

Whitey,
You can convert the WPF image to our .NET RasterImage object, then define a region in the RasterImage and use any of our image processing commands, such as AverageCommand. This will apply the blurring (averaging) effect to the region area alone.
You can then convert the RasterImage back to a WPF image.

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
#3 Posted : Monday, November 15, 2010 4:07:49 AM(UTC)

Whitey  
Whitey

Groups: Registered
Posts: 7


I've done that while saving out using your invert command after looking at one of your samples.   I'll attach the code.
I'm not sure how to make it work with an effect such as gaussian blur, or average blur.  Also, since it needs to be switched back and forth, would it be able to be used in conjunction with a mouse being held down and dragged?  Would the paint be possible with your controls?
Thanks,
Whitey
File Attachment(s):
InvertCode.txt (2kb) downloaded 27 time(s).
 
#4 Posted : Wednesday, November 17, 2010 11:38:15 AM(UTC)

jigar  
Guest

Groups: Guests
Posts: 3,022

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

I looked at your code and I see that you are cloning and combining the image.  You don't have to do that.  You can run the command directly on the myRasterImage and it will only apply the command to the region.  This will save you time.  Like this:

RasterImage myRasterImage = RasterImageMediaConverter.ConvertTo(morphImage.Source, RasterImageMediaConverterToFlags.None);
System.Drawing.Rectangle rc = new System.Drawing.Rectangle(myRasterImage.ImageWidth / 10, myRasterImage.ImageHeight / 10, myRasterImage.ImageWidth / 3, myRasterImage.ImageHeight / 3);
myRasterImage.AddRectangleToRegion(null, rc, RasterRegionCombineMode.Set);

//Modify cropped area for easy identification
InvertCommand invCommand = new InvertCommand();
invCommand.Run(myRasterImage);

As for painting while the mouse is moving will seem slow because you will have to convert back and forth between the RasterImage and the BitmapSource.  I think what you can do instead is just use the RasterImageViewer from Leadtools.Windows.Controls.Pro.dll.  The RasterImageViewer takes a RasterImage object, so you don't have to convert back and forth.  If you use the RasterImageViewer then you just need to do this:


System.Drawing.Rectangle rc = new
System.Drawing.Rectangle(myRasterImage.ImageWidth / 10,
myRasterImage.ImageHeight / 10, myRasterImage.ImageWidth / 3, myRasterImage.ImageHeight / 3);
myRasterImage.AddRectangleToRegion(null, rc, RasterRegionCombineMode.Set);

//Modify cropped area for easy identification
InvertCommand invCommand = new InvertCommand();
invCommand.Run(myRasterImage);

 
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.088 seconds.