Kerala Microsoft Users Group
Pay $0.00 for Windows Server 2008 and SQL Server 2008 licenses.

Cropping in silverlight

Latest post 02-26-2010 11:44 PM by Jinesh. 3 replies.
  • 02-25-2010 3:53 AM

    Cropping in silverlight

    Hi Guys,

        Let me know, how crop an image in silverlight.

    Filed under:
    • Post Points: 25
  • 02-25-2010 4:40 AM In reply to

    Re: Cropping in silverlight

    Reply |Contact |Answer

    Something like this should work.

     public static void CropImage(ref Image img, int height, int width)
        {

          //Clip the view size the given height and width
          RectangleGeometry r = new RectangleGeometry();
          r.Rect = new Rect(0, 0, height, width);
          img.Clip = r;
        }

     

    Thanks

    Anoop Madhusudanan

    Yet another Spiritual Programmer: See my blog for Design Patterns, Neural Nets, .NET recipes and more - http://amazedsaint.blogspot.com 

    • Post Points: 25
  • 02-26-2010 3:59 AM In reply to

    Re: Cropping in silverlight

    Reply |Contact |Answer

    Hai Anoop,

       Thank you for your answer. I developed it and worked successfully.

    Let me how can we show style like rectangle in the selected area and 

    other portions are in ashed color.

     

    • Post Points: 5
  • 02-26-2010 11:44 PM In reply to

    Re: Cropping in silverlight

    Hai,       

                    Rectangle rectcrop = new Rectangle();

                    rectcrop.SetValue(Canvas.LeftProperty, mouseHorizontalPosition);

    // take X the value when mouse button down

                    rectcrop.SetValue(Canvas.TopProperty, mouseVerticalPosition);

     // take Y the value when mouse button down

                    rectcrop.SetValue(Canvas.WidthProperty, (mouseHorizontalPositionup - mouseHorizontalPosition));

     // take X the value when mouse button up and minus it

                    rectcrop.SetValue(Canvas.HeightProperty, (mouseVerticalPositionup - mouseVerticalPosition));

     // takeY the value when mouse button up and minus it

                    rectcrop.SetValue(Rectangle.FillProperty, new SolidColorBrush(Colors.White));

                    rectcrop.SetValue(Rectangle.OpacityProperty, 0.1);

    // add this rectangle to canvas

    • Post Points: 5
Page 1 of 1 (4 items) | RSS
Pay $0.00 for Windows Server 2008 and SQL Server 2008 licenses.