Leadtools.Windows.Media.Effects Send comments on this topic. | Back to Introduction - LEADTOOLS WPF | Help Version 16.5.9.25
RotateCommandBitmapEffect Class
See Also  Members   Example 
Leadtools.Windows.Media.Effects Namespace : RotateCommandBitmapEffect Class





Rotates an image by the number of degrees specified.

Syntax

Visual Basic (Declaration) 
Public Class RotateCommandBitmapEffect 
   Inherits RasterCommandBitmapEffect
Visual Basic (Usage)Copy Code
Dim instance As RotateCommandBitmapEffect
C# 
public class RotateCommandBitmapEffect : RasterCommandBitmapEffect 
C++/CLI 
public ref class RotateCommandBitmapEffect : public RasterCommandBitmapEffect 
XAML Property Element Usage 

RotateCommandBitmapEffect ...

XAML Property Element Usage 

RotateCommandBitmapEffect ...

Example

This example will load an image, rotate it by 45 degrees then save it back to disk

Visual BasicCopy Code
Public Sub RotateCommandBitmapEffectExample(ByVal element As FrameworkElement)
   Dim effect As RotateCommandBitmapEffect = New RotateCommandBitmapEffect()
   effect.Angle = 0
   effect.Flags = RotateCommandBitmapEffectsFlags.Bicubic
   element.BitmapEffect = effect

   Dim storyboard As Storyboard = New Storyboard()

   Dim animation1 As Int32Animation = New Int32Animation()
   animation1.From = 0
   animation1.To = 36000
   animation1.Duration = New Duration(TimeSpan.Parse("0:0:5"))
   animation1.RepeatBehavior = RepeatBehavior.Forever
   animation1.AutoReverse = False

   storyboard.SetTargetName(animation1, "AnimatedBitmapEffect")
   storyboard.SetTargetProperty(animation1, New PropertyPath(RotateCommandBitmapEffect.AngleProperty))
   element.RegisterName("AnimatedBitmapEffect", effect)
   storyboard.Children.Add(animation1)

   storyboard.Begin(element)
End Sub
C#Copy Code
public void RotateCommandBitmapEffectExample(FrameworkElement element) 

   RotateCommandBitmapEffect effect = new RotateCommandBitmapEffect(); 
   effect.Angle = 0; 
   effect.Flags = RotateCommandBitmapEffectsFlags.Bicubic; 
   element.BitmapEffect = effect; 
 
   Storyboard storyboard = new Storyboard(); 
 
   Int32Animation animation1 = new Int32Animation(); 
   animation1.From = 0; 
   animation1.To = 36000; 
   animation1.Duration = new Duration(TimeSpan.Parse("0:0:5")); 
   animation1.RepeatBehavior = RepeatBehavior.Forever; 
   animation1.AutoReverse = false; 
 
   Storyboard.SetTargetName(animation1, "AnimatedBitmapEffect"); 
   Storyboard.SetTargetProperty(animation1, new PropertyPath(RotateCommandBitmapEffect.AngleProperty)); 
   element.RegisterName("AnimatedBitmapEffect", effect); 
   storyboard.Children.Add(animation1); 
 
   storyboard.Begin(element); 
}
XAMLCopy Code
<Page Title="CSAnimateEffect" Height="391" Width="300" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:lteffects="clr-namespace:Leadtools.Windows.Media.Effects;assembly=Leadtools.Windows.Media.Effects"> 
  <Grid> 
    <Image Margin="10,10,10,10" HorizontalAlignment="Center" VerticalAlignment="Center" Source="C:\Program Files\LEAD Technologies, Inc\LEADTOOLS 16\Images\slave.jpg"> 
      <Image.BitmapEffect> 
        <lteffects:RotateCommandBitmapEffect x:Name="AnimatedBitmapEffect" Angle="0" FillColor="White" Flags="Bicubic" /> 
      </Image.BitmapEffect> 
      <Image.Triggers> 
        <EventTrigger RoutedEvent="Image.Loaded"> 
          <BeginStoryboard> 
            <Storyboard> 
              <Int32Animation Storyboard.TargetName="AnimatedBitmapEffect" Storyboard.TargetProperty="Angle" From="0" To="36000" Duration="0:0:5" RepeatBehavior="Forever" AutoReverse="false" /> 
            </Storyboard> 
          </BeginStoryboard> 
        </EventTrigger> 
      </Image.Triggers> 
    </Image> 
  </Grid> 
</Page>

Remarks

This command has the following features:

  • It uses the center of the image as the center of rotation.
  • It can rotate the image clockwise or counterclockwise up to 360 degrees in 1-degree increments.
  • It can resize the image to accommodate the rotated height and width, or it can retain the original height and width, cropping the image as necessary.
  • It uses FillColor as the background color to fill any new area created by the rotation.

RotateCommandBitmapEffectsFlags.Resample and RotateCommandBitmapEffectsFlags.Bicubic can be combined with RotateCommandBitmapEffectsFlags.Resize, but they can not be combined with each other.

If RotateCommandBitmapEffectsFlags.Resize is set, then the image is resized. Otherwise, the image is cropped.

Interpolation can be done while rotating certain images. This produces superior output, eliminating the jaggedness occurring when rotating images at angles that are not multiple of 90. (ie when RotateCommandBitmapEffect.Angle is not a multiple of 9000).

Inheritance Hierarchy

System.Object
   System.Windows.Threading.DispatcherObject
      System.Windows.DependencyObject
         System.Windows.Freezable
            System.Windows.Media.Animation.Animatable
               System.Windows.Media.Effects.BitmapEffect
                  Leadtools.Windows.Media.Effects.RasterCommandBitmapEffect
                     Leadtools.Windows.Media.Effects.RotateCommandBitmapEffect

Requirements

Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Vista, Windows Server 2003 family, Windows Server 2008 family

See Also