0 Replies - 4867 Views - Last Post: 20 February 2009 - 04:09 AM Rate Topic: -----

#1 coolpjmartin  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 20-February 09

Clipping an image region and saving as new image

Posted 20 February 2009 - 04:09 AM

Help wanted clipping an image region and saving as new image....

Can someone please help me.

What I what to do is display a picture (image) and drawer a clip region using the mouse on a selected area on the image, this could be a retangle, square or a freehand shape.

I can display the image and clipped region using WPF as below. But what I cannot work out is how to save the clipped region of the image as a new bitmap image. The same problem if I create a image using pathgeometry, I cannot work out how to save the cropped part of the image.

If there is an alternative method instead of using WPF, please advice me.

c# or vb I don't mind, I just need a solution.


// Sample 4

// Create the image to clip.

Image myImage = new Image();

Uri imageUri =

new Uri(@"C:\\Documents and Settings\\All Users\\Documents\My Pictures\\Sample Pictures\\Water lilies.jpg", UriKind.Relative);

myImage.Source = new BitmapImage(imageUri);

myImage.Width = 200;

myImage.Height = 150;

myImage.HorizontalAlignment = HorizontalAlignment.Left;

// Use an EllipseGeometry to define the clip region.

EllipseGeometry myEllipseGeometry2 = new EllipseGeometry();

myEllipseGeometry2.Center = new Point(100, 75);

myEllipseGeometry2.RadiusX = 100;

myEllipseGeometry2.RadiusY = 75;

myImage.Clip = myEllipseGeometry2;

Is This A Good Question/Topic? 0
  • +

Page 1 of 1