![](dotnetdiagramimages/Leadtools_ImageProcessing_SpecialEffects_Leadtools_ImageProcessing_SpecialEffects_DiceEffectCommand.png)
Visual Basic (Declaration) | |
---|---|
Public Class DiceEffectCommand Inherits Leadtools.ImageProcessing.RasterCommand Implements IRasterCommand |
Visual Basic (Usage) | ![]() |
---|---|
Dim instance As DiceEffectCommand |
C# | |
---|---|
public class DiceEffectCommand : Leadtools.ImageProcessing.RasterCommand, IRasterCommand |
C++/CLI | |
---|---|
public ref class DiceEffectCommand : public Leadtools.ImageProcessing.RasterCommand, IRasterCommand |
Run the DiceEffectCommand on an image.
Visual Basic | ![]() |
---|---|
Public Sub DiceEffectCommandExample() Dim codecs As New RasterCodecs() codecs.ThrowExceptionsOnInvalidImages = True Dim leadImage As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Master.jpg")) ' Prepare the command Dim command As DiceEffectCommand = New DiceEffectCommand command.XBlock = 16 command.YBlock = 16 command.Randomize = 0 command.Flags = DiceEffectCommandFlags.Count Or DiceEffectCommandFlags.Border command.BorderColor = New RasterColor(0, 0, 0) ' Apply Dice Effect for this image. command.Run(leadImage) codecs.Save(leadImage, Path.Combine(LEAD_VARS.ImagesDir, "Result.jpg"), RasterImageFormat.Jpeg, 24) End Sub Public NotInheritable Class LEAD_VARS Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images" End Class |
C# | ![]() |
---|---|
public void DiceEffectCommandExample() { // Load an image RasterCodecs codecs = new RasterCodecs(); codecs.ThrowExceptionsOnInvalidImages = true; RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Master.jpg")); // Prepare the command DiceEffectCommand command = new DiceEffectCommand(); command.XBlock = 16; command.YBlock = 16; command.Randomize = 0; command.Flags = DiceEffectCommandFlags.Count | DiceEffectCommandFlags.Border; command.BorderColor = new RasterColor(0, 0, 0); // Apply Dice Effect for this image. command.Run(image); codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "Result.jpg"), RasterImageFormat.Jpeg, 24); } static class LEAD_VARS { public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images"; } |
- This command can process the whole image or a region of the image. If the image has a region, the effect is applied only to the region.
- This command divides the image into a certain number of blocks according to the Flags property, or the flags parameter of the Constructor. If the DiceEffectCommandFlags.Size flag is set then the image will be divided into blocks according to the width and height for each block. The width and height are set in the XBlock and YBlock properties, or can be designated in the Constructor.
- If the DiceEffectCommandFlags.Count flag is set then the image is divided into blocks according to the number of blocks per row and number of blocks per column. These values are also set in the XBlock and YBlock properties, or can be designated in the Constructor.
- The DiceEffectCommandFlags.Count flag or DiceEffectCommandFlags.Size flag (but not both) must be set.
- If the DiceEffectCommandFlags.Border flag is also set, borders will be drawn around the dice blocks and it will be painted using the BorderColor property (or the borderColor parameter of the Constructor). If the DiceEffectCommandFlags.ResizeImage flag is set then the image will be resized so that all blocks have the same size and so there is no remainder in the image, ensuring that all blocks in the image will be manipulated in the same way. If the DiceEffectCommandFlags.ResizeImage flag is not set then the edge blocks (which may be a different size than the inner blocks) will be treated differently than the inner blocks.
- The Dice effect command works in the following manner:
- It divides the image into a certain number of blocks.
- If the DiceEffectCommandFlags.ResizeImage flag is set, the image is resized to the closest size to have the edge blocks have the same size as the inner blocks.
- If the DiceEffectCommandFlags.ResizeImage flag is not set, then the inner blocks might have a different size and shape than the edge blocks. Each block is transformed according to its shape.
- For each block, a rotation angle is picked at random out of the following values: 0, 90, 180, and 270. The rotation angle is applied depending on the block shape (square or rectangular):
- If the block is square, it is rotated by the rotation angle.
- If the block is rectangular, it is transformed as follows:
- If the rotation angle is 0, the block remains unchanged.
- If the rotation angle is 90, the block is flipped around the x-axis.
- If the angle is 180, the block is rotated by 180.
- If the angle is 270, the block is flipped around the y-axis.
- If the DiceEffectCommandFlags.Border flag is set, the command draws borders around the blocks.
- The starting point (or "randomize value") for the random number generator is set in the Randomize property or the randomize parameter of the Constructor).
- If the randomize value is zero then the command itself selects a random value between 1 and 500 for the randomize value.
- If the randomize value is > 0, it is used as the starting point.
- Here are some tips related to the randomize point:
- The sequence of generated random numbers is the same if you use the same randomize value > 0. In other words, if you call the command twice with the same randomize value, each block will be transformed the same way.
- Calling the command 4 times with the same image and the same randomize value > 0 will leave the image blocks unchanged. So, if you call the command once, the blocks will be transformed. Call the command 3 more times and each block goes to its original transformation. Of course, if you elected to draw borders, there will be a grid drawn on the image.
- If you pass 0 for the Flags property or the flags parameter of the Constructor, the command leaves the image unchanged.
- This command supports all bits/pixel supported by LEADTOOLS.
- This command supports 12- and 16-bit grayscale and 48- and 64-bit color images. Support for 12- and 16-bit grayscale and 48- and 64-bit color images is available only in the Document/Medical toolkits.
- This command does not support signed data images.
- This command does not support 32-bit grayscale images.
System.Object
Leadtools.ImageProcessing.RasterCommand
Leadtools.ImageProcessing.SpecialEffects.DiceEffectCommand
Target Platforms: Microsoft .NET Framework 2.0, Windows 2000, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7
Reference
DiceEffectCommand MembersLeadtools.ImageProcessing.SpecialEffects Namespace
Applying Artistic Effects
PuzzleEffectCommand Class
RingEffectCommand Class
BricksTextureCommand Class
CanvasCommand Class
CloudsCommand Class
ColoredBallsCommand Class
DiffuseGlowCommand Class
Leadtools.ImageProcessing.Effects.DisplacementCommand
FragmentCommand Class
Leadtools.ImageProcessing.Core.HalfTonePatternCommand
Leadtools.ImageProcessing.Effects.MaskConvolutionCommand
MosaicTilesCommand Class
Leadtools.ImageProcessing.Effects.OffsetCommand
PerspectiveCommand Class
PlasmaCommand Class
PointillistCommand Class
RomanMosaicCommand Class
VignnetCommand Class
ZigZagCommand Class