/Visual Studio 2008/VBSL3WriteableBitmap/Screenshot.xaml
XAML | 49 lines | 49 code | 0 blank | 0 comment | 0 complexity | 8ddb4dfe1cc73ee731e806b304c9669d MD5 | raw file
- <UserControl
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" x:Class="VBSL3WriteableBitmap.Screenshot"
- mc:Ignorable="d" d:DesignWidth="479" d:DesignHeight="375" Loaded="UserControl_Loaded">
- <UserControl.Resources>
- <Storyboard x:Name="sb" RepeatBehavior="Forever">
- <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="uiElementSource" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)" Duration="00:00:00.0010000">
- <EasingDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
- </DoubleAnimationUsingKeyFrames>
- <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="uiElementSource" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationX)">
- <EasingDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
- <EasingDoubleKeyFrame KeyTime="00:00:05" Value="360"/>
- </DoubleAnimationUsingKeyFrames>
- <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="uiElementSource" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
- <EasingDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
- <EasingDoubleKeyFrame KeyTime="00:00:05" Value="0.5"/>
- </DoubleAnimationUsingKeyFrames>
- <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="uiElementSource" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
- <EasingDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
- <EasingDoubleKeyFrame KeyTime="00:00:05" Value="0.5"/>
- </DoubleAnimationUsingKeyFrames>
- </Storyboard>
- </UserControl.Resources>
- <StackPanel x:Name="LayoutRoot" Background="White">
- <TextBlock Text="WriteableBitmap is also capable of creating screenshots from non-bitmap images. However, there're some limitations. In the following sample, the above rectangle is a vector graphic (in a Canvas). The below one is a screenshot created rapidly using the Canvas. As you can see, the ScaleTransform and ShaderEffect are respected, but the Projection is lost." TextWrapping="Wrap"/>
- <Canvas x:Name="uiElementSource" Height="300" Width="300" HorizontalAlignment="Center" RenderTransformOrigin="0.5,0.5">
- <Canvas.Projection>
- <PlaneProjection/>
- </Canvas.Projection>
- <Canvas.RenderTransform>
- <TransformGroup>
- <ScaleTransform/>
- <SkewTransform/>
- <RotateTransform/>
- <TranslateTransform/>
- </TransformGroup>
- </Canvas.RenderTransform>
- <Rectangle Fill="Red" Height="200" Width="200" Canvas.Left="50" Canvas.Top="50">
- <Rectangle.Effect>
- <DropShadowEffect Color="#FF0095FF"/>
- </Rectangle.Effect>
- </Rectangle>
- </Canvas>
- <Image x:Name="img" Height="300" Width="300" Stretch="None"/>
- <TextBlock Text="Save the screenshot to a bmp file. Note the Projection is lost, and all empty pixels are rendered in black (000000), due to the limitation of WriteableBitmap." TextWrapping="Wrap"/>
- <Button x:Name="SaveFileButton" Content="Save" Click="SaveFileButton_Click"/>
- </StackPanel>
- </UserControl>