Crops a BitmapSource.
Assembly: PresentationCore (in PresentationCore.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
implements the ISupportInitialize interface to optimize initialization on multiple properties. Property changes can occur only during object initialization. Call BeginInit to signal that initialization has begun and EndInit to signal that initialization has completed. After initialization, property changes are ignored.
objects created by using the CroppedBitmap(BitmapSource, Int32Rect) constructor are automatically initialized, and properties cannot be changed.
Metadata tags related to image data must be updated if an image is saved to a file after a transform is applied.
Use the SourceRect property of this class to define the area of the bitmap that is to be cropped.
This example shows how to crop an image using .
is primarily used when encoding a cropped version of an image to save out to a file. To crop an image for display purposes see the How to: Create a Clip Region topic.
The following Extensible Application Markup Language (XAML) defines resources used within the samples below.
The following example creates an image using a as its source.
The can also be used as the source of another , chaining the cropping. Note that the SourceRect uses values that are relative to the source cropped bitmap and not the initial image.
For the complete sample, see Image Element Sample.
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.