Results 1 to 3 of 3

Thread: Help wanted clipping an image region

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2006
    Posts
    10

    Help wanted clipping an image region

    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 think this could be done using path geometries and clip.

    http://msdn.microsoft.com/en-us/libr...08(VS.85).aspx

    Once I have marked the clip region, I then want to be able to save the selected clipped image as a new image (bitmap).

    but I am not sure how to do this.

    does anyone have any sample code, or suggestions.

    this can be in either vb.net ot c#

    Thanks

  2. #2
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: Help wanted clipping an image region

    Have a look at this project, it seems to do what you are looking for:

    http://www.codeproject.com/KB/WPF/ImageCropper.aspx

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2006
    Posts
    10

    Re: Help wanted clipping an image region

    Hi Thanks you for your reply. I have looked at the sugested examples, and can managed to display a clipped image, what I cannot work out is how to save that clipped image as a new bitmap image.

    In the example below, if I create a clipped region around an image, how would I save the clipped bitmap.

    The same if I created an image and added a pathgeometry to only show part of the image how to I save only the clipped part of the image.

    // 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;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width