Quantcast
Channel: Silverlight 5 forum
Viewing all articles
Browse latest Browse all 1083

Crop Image in Silverlight5

$
0
0

Hi Guys,

On printing time I want to crop Image in Silverlight5.I tried with this code.Actually I want that Image need to corp from bellow,I tried with this.

For WPF this code is working fine..

  CroppedBitmap cb = new CroppedBitmap(image,
                        new Int32Rect(0,0,
                            Math.Min((int)image.Width, image.PixelWidth),
                            Math.Min((int)image.Height-80, image.PixelHeight)));

Here Image =  var image = GenerateBitmapSource(rootElement);

But in Silverlight we don't have CroppedBitmap .So I tried with bellow code

WriteableBitmap cb = new WriteableBitmap(image.PixelWidth, image.PixelHeight-80);

                var imageSnapshot = new Image()
                {
                    Source = cb,
                    Stretch = stretchToFit ? Stretch.Uniform : Stretch.None,
                    VerticalAlignment = VerticalAlignment.Center,
                    HorizontalAlignment = HorizontalAlignment.Center,
                };

rootElement is FrameworkElement..

But it is not working Please help....

Regards,

Rahman




Viewing all articles
Browse latest Browse all 1083

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>