Leadtools.Windows.Media.Effects Send comments on this topic. | Back to Introduction - All Topics | Help Version 15.02.15
PuzzleEffectCommandBitmapEffect Class
See Also  Members   Example 
Leadtools.Windows.Media.Effects.SpecialEffects Namespace : PuzzleEffectCommandBitmapEffect Class





Splits the image into square blocks and randomizes these blocks inside the image.

Syntax

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

PuzzleEffectCommandBitmapEffect ...

Example

Visual BasicCopy Code
Public Sub PuzzleEffectCommandBitmapEffectExample(ByVal element As FrameworkElement)
   Dim effect As PuzzleEffectCommandBitmapEffect = New PuzzleEffectCommandBitmapEffect()
   effect.BorderColor = Color.FromRgb(0, 0, 0)
   effect.Flags = PuzzleEffectCommandBitmapEffectsFlags.Border Or PuzzleEffectCommandBitmapEffectsFlags.Shuffle Or PuzzleEffectCommandBitmapEffectsFlags.Count Or PuzzleEffectCommandBitmapEffectsFlags.Resize
   effect.Randomize = 0
   effect.XBlock = 10
   effect.YBlock = 10
   element.BitmapEffect = effect

   Dim storyboard As Storyboard = New Storyboard()

   Dim animation1 As Int32Animation = New Int32Animation()
   animation1.From = 10
   animation1.To = 50
   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(PuzzleEffectCommandBitmapEffect.XBlockProperty))
   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(PuzzleEffectCommandBitmapEffect.YBlockProperty))
   element.RegisterName("AnimatedBitmapEffect", effect)
   storyboard.Children.Add(animation2)

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

   PuzzleEffectCommandBitmapEffect effect = new PuzzleEffectCommandBitmapEffect(); 
   effect.BorderColor = Color.FromRgb(0, 0, 0); 
   effect.Flags = PuzzleEffectCommandBitmapEffectsFlags.Border | PuzzleEffectCommandBitmapEffectsFlags.Shuffle | PuzzleEffectCommandBitmapEffectsFlags.Count | PuzzleEffectCommandBitmapEffectsFlags.Resize; 
   effect.Randomize = 0; 
   effect.XBlock = 10; 
   effect.YBlock = 10; 
   element.BitmapEffect = effect; 
 
   Storyboard storyboard = new Storyboard(); 
 
   Int32Animation animation1 = new Int32Animation(); 
   animation1.From = 10; 
   animation1.To = 50; 
   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(PuzzleEffectCommandBitmapEffect.XBlockProperty)); 
   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(PuzzleEffectCommandBitmapEffect.YBlockProperty)); 
   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 15\Images\slave.jpg"> 
      <Image.BitmapEffect> 
        <lteffects:PuzzleEffectCommandBitmapEffect x:Name="AnimatedBitmapEffect" BorderColor="White" Flags="Border, Shuffle, Count, Resize" Randomize="0" XBlock="10" YBlock="10" /> 
      </Image.BitmapEffect> 
      <Image.Triggers> 
        <EventTrigger RoutedEvent="Image.Loaded"> 
          <BeginStoryboard> 
            <Storyboard> 
              <Int32Animation Storyboard.TargetName="AnimatedBitmapEffect" Storyboard.TargetProperty="XBlock" From="10" To="50" Duration="0:0:5" RepeatBehavior="Forever" AutoReverse="true" /> 
              <Int32Animation Storyboard.TargetName="AnimatedBitmapEffect" Storyboard.TargetProperty="YBlock" From="10" To="50" Duration="0:0:5" RepeatBehavior="Forever" AutoReverse="true" /> 
            </Storyboard> 
          </BeginStoryboard> 
        </EventTrigger> 
      </Image.Triggers> 
    </Image> 
  </Grid> 
</Page>

Remarks

  • Splits the image into a certain number of blocks according to the flags. If the PuzzleEffectCommandBitmapEffectsFlags.Size flag is set, then the image will be divided into blocks using the XBlock and YBlock properties for the dimensions of the blocks. If the PuzzleEffectCommandBitmapEffectsFlags.Count flag is set, then the image will be divided into blocks using the xblock and ybBlock values for the number of blocks per row and number of blocks per column.
  • If the PuzzleEffectCommandBitmapEffectsFlags.Resize flag is not set, the edge blocks might have a different size than the inner blocks. This means the edge blocks will be manipulated differently than the inner blocks. The inner blocks that have the same dimensions will be shuffled around. The right edge blocks will be shuffled together and the bottom edge blocks will be shuffled together.
  • If the PuzzleEffectCommandBitmapEffectsFlags.Resize flag is set, the image will be resized to be sure that all blocks have the same dimensions. In this case, the edge blocks will not be treated differently than the inner blocks.
  • If the PuzzleEffectCommandBitmapEffectsFlags.Border flag is set, borders will be drawn with the color set in the BorderColor property. If the PuzzleEffectCommandBitmapEffectsFlags.Border flag is not set, no borders will be drawn.
  • If the PuzzleEffectCommandBitmapEffectsFlags.Shuffle flag is not set, the blocks will appear in their original positions. If the PuzzleEffectCommandBitmapEffectsFlags.Shuffle flag is set then the blocks will appear randomized. The randomization process will be controlled by the Randomize property, as follows:
  • If the randomize value is 0, the command will select the starting point for the randomize process. You will get a different result every time you call the command with the randomize value = 0.
  • If the randomize value is greater than 0, the command will use this value as a starting point for the randomize process. You will get the same result every time you call the command with the same randomize value > 0.
  • Edge blocks that have the same size as inner blocks might move into the middle of the resulting image. Edge blocks with a different size than inner blocks will remain on the edge.
  • You must set the PuzzleEffectCommandBitmapEffectsFlags.Size flag or the Count flag (but not both) for the command to affect the image. If you set the flags to 0, the command leaves the image unchanged.
  • 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.PuzzleEffectCommandBitmapEffect

Requirements

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

See Also