Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 4
 Source Property
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2010/.NET Framework 4

Other versions are also available for the following:
.NET Framework Class Library
TransformedBitmap..::.Source Property

Gets or sets the source for the bitmap.

Namespace:  System.Windows.Media.Imaging
Assembly:  PresentationCore (in PresentationCore.dll)
Visual Basic
Public Property Source As BitmapSource
C#
public BitmapSource Source { get; set; }
Visual C++
public:
property BitmapSource^ Source {
    BitmapSource^ get ();
    void set (BitmapSource^ value);
}
F#
member Source : BitmapSource with get, set

Property Value

Type: System.Windows.Media.Imaging..::.BitmapSource
The source for the bitmap. The default value is nullNothingnullptra null reference (Nothing in Visual Basic).

Identifier field

SourceProperty

Metadata properties set to true

None

You can chain a TransformedBitmap to another BitmapSource by setting the Source property of the TransformedBitmap to the BitmapSource that you want. See How to: Chain BitmapSource Objects Together for an example of chaining.

This example shows how to rotate an image 90 degrees by using a Rotation property of a BitmapImage.

XAML
<Image Width="150" Margin="5" Grid.Column="0" Grid.Row="1">
   <Image.Source>
     <BitmapImage UriSource="/sampleImages/watermelon.jpg" Rotation="Rotate90" />
   </Image.Source>
</Image>
Visual Basic
'Create Image element
Dim rotated270 As New Image()
rotated270.Width = 150

'Create source
Dim bi As New BitmapImage()
'BitmapImage properties must be in a BeginInit/EndInit block
bi.BeginInit()
bi.UriSource = New Uri("pack://application:,,/sampleImages/watermelon.jpg")
'Set image rotation
bi.Rotation = Rotation.Rotate270
bi.EndInit()
'set image source
rotated270.Source = bi
C#
//Create Image element
Image rotated270 = new Image();
rotated270.Width = 150;

//Create source
BitmapImage bi = new BitmapImage();
//BitmapImage properties must be in a BeginInit/EndInit block
bi.BeginInit();
bi.UriSource = new Uri(@"pack://application:,,/sampleImages/watermelon.jpg");
//Set image rotation
bi.Rotation = Rotation.Rotate270;
bi.EndInit();
//set image source
rotated270.Source = bi;

More Code

How to: Chain BitmapSource Objects TogetherThis example shows how you can apply a variety of effects to an image source by chaining multiple BitmapSource derived objects together.

.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker