Visual Basic (Declaration) | |
---|---|
Public Class RingEffectCommand Inherits Leadtools.ImageProcessing.RasterCommand Implements IRasterCommand |
Visual Basic (Usage) | Copy Code |
---|---|
Dim instance As RingEffectCommand |
C# | |
---|---|
public class RingEffectCommand : Leadtools.ImageProcessing.RasterCommand, IRasterCommand |
C++/CLI | |
---|---|
public ref class RingEffectCommand : public Leadtools.ImageProcessing.RasterCommand, IRasterCommand |
Run the Leadtools.ImageProcessing.SpecialEffects.RingEffectCommand on an image.
Visual Basic | Copy Code |
---|---|
Public Sub RingEffectCommandExample() 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 RingEffectCommand = New RingEffectCommand command.Origin = New LeadPoint(leadImage.Width \ 2, leadImage.Height \ 2) command.Radius = command.Origin.X command.RingCount = 10 command.Randomize = 0 command.Color = New RasterColor(0, 0, 0) command.Angle = 100 command.Flags = RingEffectCommandFlags.Color Or RingEffectCommandFlags.FixedAngle Or RingEffectCommandFlags.MaxRadius ' Apply a ring effect to this image with origin (Origin). The maximum ring radius is equal to half of the image's width. Draw 10 rings, fill the undefined areas with the Black color and the shift angle is equal to 1 degrees. Note that you will have undefined areas only if the image width is greater than the image height. 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# | Copy Code |
---|---|
public void RingEffectCommandExample() { // Load an image RasterCodecs codecs = new RasterCodecs(); codecs.ThrowExceptionsOnInvalidImages = true; RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Master.jpg")); // Prepare the command RingEffectCommand command = new RingEffectCommand(); command.Origin = new LeadPoint((image.Width / 2), (image.Height / 2)); command.Radius = command.Origin.X; command.RingCount = 10; command.Randomize = 0; command.Color = new RasterColor(0,0,0); command.Angle = 100; command.Flags = RingEffectCommandFlags.Color | RingEffectCommandFlags.FixedAngle | RingEffectCommandFlags.MaxRadius; // Apply a ring effect to this image with origin (Origin). The maximum ring radius is equal to half of the image's width. Draw 10 rings, fill the undefined areas with the Black color and the shift angle is equal to 1 degrees. Note that you will have undefined areas only if the image width is greater than the image height. 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.
- 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 RingEffectCommandFlags.FixedAngle flag is not set, or will use the angle specified by the Angle property, or the angle parameter of the Constructor if the RingEffectCommandFlags.FixedAngle flag is set).
- If the RingEffectCommandFlags.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, or the randomize parameter if you are using the appropriate RingEffectCommand Constructor 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 or the origin parameter if you are using the appropriate RingEffectCommand Constructor. 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 or the radius parameter of the Constructor when the RingEffectCommandFlags.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 (RingEffectCommandFlags.NoChange flag is set) or
Repeat edge pixels (RingEffectCommandFlags.Repeat flag is set) or
Fill the undefined area with color that is stored in the Color property, or the color parameter if you are using the appropriate RingEffectCommand Constructor, if the RingEffectCommandFlags.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 RingEffectCommandFlags.FixedAngle flag is set, each ring will be rotated against its inner ring by the value specified in the Angle property, or the angle parameter if you are using the appropriate RingEffectCommand Constructor. 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 RingEffectCommandFlags.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 RingEffectCommandFlags.Radius flag is set, the radius value is the width of each ring
- If the RingEffectCommandFlags.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.
- 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.RingEffectCommand
Target Platforms: Microsoft .NET Framework 2.0, Windows 2000, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7
Reference
RingEffectCommand MembersLeadtools.ImageProcessing.SpecialEffects Namespace
Applying Artistic Effects
Leadtools.ImageProcessing.Effects.MosaicCommand
Leadtools.ImageProcessing.Effects.PicturizeListCommand
Leadtools.ImageProcessing.Effects.PicturizeSingleCommand
PixelateCommand Class
Leadtools.ImageProcessing.Effects.CubismCommand
DiceEffectCommand Class
PuzzleEffectCommand 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