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

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

Gets or sets the source for the bitmap. This is a dependency property.

Namespace:  System.Windows.Media.Imaging
Assembly:  PresentationCore (in PresentationCore.dll)
Visual Basic (Declaration)
Public Property Source As BitmapSource
Visual Basic (Usage)
Dim instance As TransformedBitmap
Dim value As BitmapSource

value = instance.Source

instance.Source = value
C#
public BitmapSource Source { get; set; }
Visual C++
public:
property BitmapSource^ Source {
    BitmapSource^ get ();
    void set (BitmapSource^ value);
}
JScript
public function get Source () : BitmapSource
public function set Source (value : BitmapSource)
XAML
For XAML information, see the BitmapSource type.

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 Together This example shows how you can apply a variety of effects to an image source by chaining multiple BitmapSource derived objects together.

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.

.NET Framework

Supported in: 3.5, 3.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker