Load image with BitmapImage : Image « Windows Presentation Foundation « C# / CSharp Tutorial

Home
C# / CSharp Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statement
5.String
6.struct
7.Class
8.Operator Overload
9.delegate
10.Attribute
11.Data Structure
12.Assembly
13.Date Time
14.Development
15.File Directory Stream
16.Preprocessing Directives
17.Regular Expression
18.Generic
19.Reflection
20.Thread
21.I18N Internationalization
22.LINQ
23.GUI Windows Forms
24.Windows Presentation Foundation
25.Windows Communication Foundation
26.Workflow
27.2D
28.Design Patterns
29.Windows
30.XML
31.XML LINQ
32.ADO.Net
33.Network
34.Directory Services
35.Security
36.unsafe
C# / C Sharp
C# / C Sharp by API
C# / CSharp Open Source
C# / CSharp Tutorial » Windows Presentation Foundation » Image 
24.93.14.Load image with BitmapImage
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="ImageElementExample.TransformedImageExample"
    Title="Transformed Image Example"
    Loaded="PageLoaded">
   <Page.Resources>
      <BitmapImage x:Key="masterImage" UriSource="c:\image.jpg"/>
   </Page.Resources>
   <DockPanel>
      <Image Source="{StaticResource masterImage}" Width="150" Margin="5"/>
      <Grid Name="transformedGrid">
         <Image Width="150" Margin="5" Grid.Column="0" Grid.Row="1">
           <Image.Source>
             <TransformedBitmap Source="c:\image.jpg" >
               <TransformedBitmap.Transform>
                 <RotateTransform Angle="90"/>
               </TransformedBitmap.Transform>
             </TransformedBitmap>
           </Image.Source>
         </Image>
      </Grid>
   </DockPanel>
</Page>
//File:Window.xaml.cs

using System;
using System.Windows;
using System.Windows.Documents;
using System.Windows.Controls;
using System.Windows.Navigation;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;


namespace ImageElementExample
{
   public partial class TransformedImageExample : Page
   {
      public TransformedImageExample()
      {
      }

      public void PageLoaded(object sender, RoutedEventArgs args)
      {
         Image rotated90 = new Image();
         rotated90.Width = 150;

         TransformedBitmap tb = new TransformedBitmap();

         BitmapImage bi = new BitmapImage();
         bi.BeginInit();
         bi.UriSource = new Uri(@"file:///c:/image.jpg", UriKind.RelativeOrAbsolute);
         bi.EndInit();

         tb.BeginInit();
         tb.Source = bi;

         RotateTransform transform = new RotateTransform(90);
         tb.Transform = transform;
         tb.EndInit();

         rotated90.Source = tb;

         Grid.SetColumn(rotated90, 1);
         Grid.SetRow(rotated90, 1);
         transformedGrid.Children.Add(rotated90);
      }
   }
}
WPF Load Image With Bitmap Image
24.93.Image
24.93.1.Read bitmap from Uri
24.93.2.Image with ContextMenuImage with ContextMenu
24.93.3.Animated Clip ExamplesAnimated Clip Examples
24.93.4.Triangular Clip ExampleTriangular Clip Example
24.93.5.Elliptical Clip ExampleElliptical Clip Example
24.93.6.ImageBrush within a DrawingBrush.ImageBrush within a DrawingBrush.
24.93.7.Using an Image as an Opacity MaskUsing an Image as an Opacity Mask
24.93.8.Display a Static ImageDisplay a Static Image
24.93.9.Set opacity for ImageSet opacity for Image
24.93.10.Set tooltip for ImageSet tooltip for Image
24.93.11.Using the Jpeg ImageUsing the Jpeg Image
24.93.12.Image elementImage element
24.93.13.Image as ResourceImage as Resource
24.93.14.Load image with BitmapImageLoad image with BitmapImage
24.93.15.Load image in your code and add to gridLoad image in your code and add to grid
24.93.16.Use CroppedBitmap in codeUse CroppedBitmap in code
24.93.17.Transformed image exampleTransformed image example
24.93.18.Use Render Target BitmapUse Render Target Bitmap
24.93.19.Load image from a URILoad image from a URI
24.93.20.Modify Image PixelsModify Image Pixels
24.93.21.Add Caption for an ImageAdd Caption for an Image
24.93.22.Load image source from a hard code directoryLoad image source from a hard code directory
24.93.23.FormatConvertedBitmap DestinationFormat=Gray4FormatConvertedBitmap DestinationFormat=Gray4
24.93.24.Create Image from BitmapImage
24.93.25.Assign Image to window content
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.