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





Divides the image into the specified number of rings. Each ring is rotated according to a rotation angle. The rotation angle for each ring will be chosen randomly by the command or can be passed to the command.

Syntax

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

RingEffectCommandBitmapEffect ...

XAML Property Element Usage 

RingEffectCommandBitmapEffect ...

Example

Visual BasicCopy Code
Public Sub RingEffectCommandBitmapEffectExample(ByVal element As FrameworkElement)
   Dim effect As RingEffectCommandBitmapEffect = New RingEffectCommandBitmapEffect()
   effect.Angle = 100
   effect.Flags = RingEffectCommandBitmapEffectsFlags.Color Or RingEffectCommandBitmapEffectsFlags.FixedAngle Or RingEffectCommandBitmapEffectsFlags.MaxRadius
   effect.Origin = New System.Windows.Point(140, 105)
   effect.Radius = 50
   effect.Randomize = 0
   effect.RingCount = 10
   effect.Color = Color.FromRgb(0, 0, 0)
   element.BitmapEffect = effect

   Dim storyboard As Storyboard = New Storyboard()

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

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

   Dim animation2 As Int32Animation = New Int32Animation()
   animation2.From = 10
   animation2.To = 50
   animation2.Duration = New Duration(TimeSpan.Parse("0:0:5"))
   animation2.RepeatBehavior = RepeatBehavior.Forever
   animation2.AutoReverse = True

   storyboard.SetTargetName(animation2, "AnimatedBitmapEffect")
   storyboard.SetTargetProperty(animation2, New PropertyPath(RingEffectCommandBitmapEffect.RingCountProperty))
   element.RegisterName("AnimatedBitmapEffect", effect)
   storyboard.Children.Add(animation2)

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

   RingEffectCommandBitmapEffect effect = new RingEffectCommandBitmapEffect(); 
   effect.Angle = 100; 
   effect.Flags = RingEffectCommandBitmapEffectsFlags.Color | RingEffectCommandBitmapEffectsFlags.FixedAngle | RingEffectCommandBitmapEffectsFlags.MaxRadius; 
   effect.Origin = new Point(140, 105); 
   effect.Radius = 50; 
   effect.Randomize = 0; 
   effect.RingCount = 10; 
   effect.Color = Color.FromRgb(0, 0, 0); 
   element.BitmapEffect = effect; 
 
   Storyboard storyboard = new Storyboard(); 
 
   Int32Animation animation1 = new Int32Animation(); 
   animation1.From = 100; 
   animation1.To = 4500; 
   animation1.Duration = new Duration(TimeSpan.Parse("0:0:5")); 
   animation1.RepeatBehavior = RepeatBehavior.Forever; 
   animation1.AutoReverse = true; 
 
   Storyboard.SetTargetName(animation1, "AnimatedBitmapEffect"); 
   Storyboard.SetTargetProperty(animation1, new PropertyPath(RingEffectCommandBitmapEffect.AngleProperty)); 
   element.RegisterName("AnimatedBitmapEffect", effect); 
   storyboard.Children.Add(animation1); 
 
   Int32Animation animation2 = new Int32Animation(); 
   animation2.From = 10; 
   animation2.To = 50; 
   animation2.Duration = new Duration(TimeSpan.Parse("0:0:5")); 
   animation2.RepeatBehavior = RepeatBehavior.Forever; 
   animation2.AutoReverse = true; 
 
   Storyboard.SetTargetName(animation2, "AnimatedBitmapEffect"); 
   Storyboard.SetTargetProperty(animation2, new PropertyPath(RingEffectCommandBitmapEffect.RingCountProperty)); 
   element.RegisterName("AnimatedBitmapEffect", effect); 
   storyboard.Children.Add(animation2); 
 
   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.SpecialEffects;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:RingEffectCommandBitmapEffect x:Name="AnimatedBitmapEffect" Angle="100" Flags="Color, FixedAngle, MaxRadius" Origin="140, 105" Radius="50" Randomize="0" RingCount="10" /> 
      </Image.BitmapEffect> 
      <Image.Triggers> 
        <EventTrigger RoutedEvent="Image.Loaded"> 
          <BeginStoryboard> 
            <Storyboard> 
              <Int32Animation Storyboard.TargetName="AnimatedBitmapEffect" Storyboard.TargetProperty="Angle" From="100" To="4500" Duration="0:0:5" RepeatBehavior="Forever" AutoReverse="true" /> 
              <Int32Animation Storyboard.TargetName="AnimatedBitmapEffect" Storyboard.TargetProperty="RingCount" From="10" To="50" Duration="0:0:5" RepeatBehavior="Forever" AutoReverse="true" /> 
            </Storyboard> 
          </BeginStoryboard> 
        </EventTrigger> 
      </Image.Triggers> 
    </Image> 
  </Grid> 
</Page>

Remarks

  • Divides the image into a certain number of rings. Each ring is rotated compared to its inner ring according to a shift angle. The command will pick the shift angle at random if the RingEffectCommandBitmapEffectsFlags.FixedAngle flag is not set, or will use the angle specified by the Angle property, if the RingEffectCommandBitmapEffectsFlags.FixedAngle flag is set).
  • If the RingEffectCommandBitmapEffectsFlags.FixedAngle flag is not set then the command will pick the shift angle randomly. The starting point (that is, the "randomize value") for the random number generator is set in the Randomize property, as follows:
  • If the randomize value is zero then the command will select a random value between 1 and 500 for the randomize value.
  • If the randomize value is > 0, it will be used for the randomize value. Note that randomize value should be between 1 and 500 in this case.
  • Although the numbers generated are random, if you start with the same randomize value you will always get the same sequence of random numbers. This means that if you call the command twice with the same randomize value, you will get the same result.
  • The center of the rings is determined by the Origin property. The command calculates the width of each ring by dividing the maximum radius by the number of rings. The maximum radius is in the Radius property when the RingEffectCommandBitmapEffectsFlags.MaxRadius flag is set.
  • The minimum width of each circle is 2. If the result of the division is less than 2, the command will draw ((radius value) / 2) rings, each ring having a width of 2.
  • Rings with a large radius might not be completely inside the image. We will refer to these as "incomplete rings". We will refer to a portion of the ring that is outside the image as "undetermined portion". When you rotate an incomplete ring, an undetermined portion of the ring might come into view. The command has 3 ways of specifying the output of the pixels where undetermined portions come into view:
  • Leave original image pixels unchanged (RingEffectCommandBitmapEffectsFlags.NoChange flag is set) or
    Repeat edge pixels (RingEffectCommandBitmapEffectsFlags.Repeat flag is set) or
    Fill the undefined area with color that is stored in the Color property, if the RingEffectCommandBitmapEffectsFlags.Color flag is set).
  • The determined portion of the ring will always displace the original image pixels.
  • The image is split into an innermost circle and a number of rings. The innermost circle will not be rotated. Each ring is rotated compared to the inner ring. The rotation angle is as follows:
  • If the RingEffectCommandBitmapEffectsFlags.FixedAngle flag is set, each ring will be rotated against its inner ring by the value specified in the Angle property. In other words, each index will be rotated against the original position by the angle value * <ring index>. (The index is 0-based. The innermost circle is considered to have an index of 0 and will not be rotated).
  • If the RingEffectCommandBitmapEffectsFlags.FixedAngle flag is not set, the command will pick random rotation angles for each ring.
  • The width of the ring is determined as follows:
  • If the RingEffectCommandBitmapEffectsFlags.Radius flag is set, the radius value is the width of each ring
  • If the RingEffectCommandBitmapEffectsFlags.MaxRadius flag is set, the radius value will be the maximum ring radius. In this case, the width of each ring will be ((radius value) / (Ring count value + 1)).
  • This command supports all bits/pixel supported by LEADTOOLS for WPF.
  • This command does not support signed data images.

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.SpecialEffects.RingEffectCommandBitmapEffect

Requirements

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

See Also