LEADTOOLS Special Effects (Leadtools.SpecialEffects assembly) Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.30
DrawEffect(IntPtr,Point,IntPtr,Rectangle,SpecialEffectsType,Int32,Int32,Int32,Int32,Int32,Int32,Boolean,Color,Int32,Color,Int32,SpecialEffectsProgress) Method
See Also 
Leadtools.SpecialEffects Namespace > SpecialEffectsProcessor Class > DrawEffect Method : DrawEffect(IntPtr,Point,IntPtr,Rectangle,SpecialEffectsType,Int32,Int32,Int32,Int32,Int32,Int32,Boolean,Color,Int32,Color,Int32,SpecialEffectsProgress) Method



srcHdc
Handle to the source device context.
srcPoint
Point object of the origin of the source rectangle.
destHdc
Handle to the destination device context.
destRect
Rectangle to be used as the display destination rectangle.
effectType
Effect to apply when painting. For valid values, refer to SpecialEffectsType.
grain
Graining size. This is the smallest size (pixel width or height) to be updated when painting an effect. Using a small grain makes the painting smoother, but takes longer to paint. Using a large grain makes the painting more coarse, but paints faster. If the effectType parameter is from the Wave class this represents the duration or height of the wave. Valid values are 1 to 256.
delay
Delay between graining steps, in milliseconds.
speed
Speed of the wave. Valid values are 1 to 256. This parameter is valid only if the effectType parameter is from the Wave class.
cycles
Number of cycles or repetitions used to draw the wave. This parameter is valid only if the effectType parameter is from the Wave class.
pass
Pass number when using a pattern brush. Use 1 for painting in one pass.
maxPass
Maximum passes for a pattern brush. Use 1 for painting in one pass.
transparency
True to implement transparency by not painting pixels of the color specified in the transparentColor parameter; False if transparency is not implemented.
transparentColor
value that specifies the transparent color.
wandWidth
Wand width, in pixels.
wandColor
Value that specifies the wand color.
rasterOperation
Windows ROP code for display. This parameter takes the same codes as the Windows BitBlt method. For ordinary painting, use SRCCOPY.
progressCallback
Callback method that will be called when the Effect is started to determine the status for the effect.
srcHdc
Handle to the source device context.
srcPoint
Point object of the origin of the source rectangle.
destHdc
Handle to the destination device context.
destRect
Rectangle to be used as the display destination rectangle.
effectType
Effect to apply when painting. For valid values, refer to SpecialEffectsType.
grain
Graining size. This is the smallest size (pixel width or height) to be updated when painting an effect. Using a small grain makes the painting smoother, but takes longer to paint. Using a large grain makes the painting more coarse, but paints faster. If the effectType parameter is from the Wave class this represents the duration or height of the wave. Valid values are 1 to 256.
delay
Delay between graining steps, in milliseconds.
speed
Speed of the wave. Valid values are 1 to 256. This parameter is valid only if the effectType parameter is from the Wave class.
cycles
Number of cycles or repetitions used to draw the wave. This parameter is valid only if the effectType parameter is from the Wave class.
pass
Pass number when using a pattern brush. Use 1 for painting in one pass.
maxPass
Maximum passes for a pattern brush. Use 1 for painting in one pass.
transparency
True to implement transparency by not painting pixels of the color specified in the transparentColor parameter; False if transparency is not implemented.
transparentColor
value that specifies the transparent color.
wandWidth
Wand width, in pixels.
wandColor
Value that specifies the wand color.
rasterOperation
Windows ROP code for display. This parameter takes the same codes as the Windows BitBlt method. For ordinary painting, use SRCCOPY.
progressCallback
Callback method that will be called when the Effect is started to determine the status for the effect.
Performs a bit-block transfer of the color data corresponding to a rectangle of pixels from the specified source device context into a destination device context, while applying a special effect.

Syntax

Visual Basic (Declaration) 
Overloads Public Sub DrawEffect( _
   ByVal srcHdc As IntPtr, _
   ByVal srcPoint As Point, _
   ByVal destHdc As IntPtr, _
   ByVal destRect As Rectangle, _
   ByVal effectType As SpecialEffectsType, _
   ByVal grain As Integer, _
   ByVal delay As Integer, _
   ByVal speed As Integer, _
   ByVal cycles As Integer, _
   ByVal pass As Integer, _
   ByVal maxPass As Integer, _
   ByVal transparency As Boolean, _
   ByVal transparentColor As Color, _
   ByVal wandWidth As Integer, _
   ByVal wandColor As Color, _
   ByVal rasterOperation As Integer, _
   ByVal progressCallback As SpecialEffectsProgress _
) 
Visual Basic (Usage)Copy Code
Dim instance As SpecialEffectsProcessor
Dim srcHdc As IntPtr
Dim srcPoint As Point
Dim destHdc As IntPtr
Dim destRect As Rectangle
Dim effectType As SpecialEffectsType
Dim grain As Integer
Dim delay As Integer
Dim speed As Integer
Dim cycles As Integer
Dim pass As Integer
Dim maxPass As Integer
Dim transparency As Boolean
Dim transparentColor As Color
Dim wandWidth As Integer
Dim wandColor As Color
Dim rasterOperation As Integer
Dim progressCallback As SpecialEffectsProgress
 
instance.DrawEffect(srcHdc, srcPoint, destHdc, destRect, effectType, grain, delay, speed, cycles, pass, maxPass, transparency, transparentColor, wandWidth, wandColor, rasterOperation, progressCallback)
C# 
public void DrawEffect( 
   IntPtr srcHdc,
   Point srcPoint,
   IntPtr destHdc,
   Rectangle destRect,
   SpecialEffectsType effectType,
   int grain,
   int delay,
   int speed,
   int cycles,
   int pass,
   int maxPass,
   bool transparency,
   Color transparentColor,
   int wandWidth,
   Color wandColor,
   int rasterOperation,
   SpecialEffectsProgress progressCallback
)
C++/CLI 
public:
void DrawEffect( 
   IntPtr srcHdc,
   Point srcPoint,
   IntPtr destHdc,
   Rectangle destRect,
   SpecialEffectsType effectType,
   int grain,
   int delay,
   int speed,
   int cycles,
   int pass,
   int maxPass,
   bool transparency,
   Color transparentColor,
   int wandWidth,
   Color wandColor,
   int rasterOperation,
   SpecialEffectsProgress^ progressCallback
) 

Parameters

srcHdc
Handle to the source device context.
srcPoint
Point object of the origin of the source rectangle.
destHdc
Handle to the destination device context.
destRect
Rectangle to be used as the display destination rectangle.
effectType
Effect to apply when painting. For valid values, refer to SpecialEffectsType.
grain
Graining size. This is the smallest size (pixel width or height) to be updated when painting an effect. Using a small grain makes the painting smoother, but takes longer to paint. Using a large grain makes the painting more coarse, but paints faster. If the effectType parameter is from the Wave class this represents the duration or height of the wave. Valid values are 1 to 256.
delay
Delay between graining steps, in milliseconds.
speed
Speed of the wave. Valid values are 1 to 256. This parameter is valid only if the effectType parameter is from the Wave class.
cycles
Number of cycles or repetitions used to draw the wave. This parameter is valid only if the effectType parameter is from the Wave class.
pass
Pass number when using a pattern brush. Use 1 for painting in one pass.
maxPass
Maximum passes for a pattern brush. Use 1 for painting in one pass.
transparency
True to implement transparency by not painting pixels of the color specified in the transparentColor parameter; False if transparency is not implemented.
transparentColor
value that specifies the transparent color.
wandWidth
Wand width, in pixels.
wandColor
Value that specifies the wand color.
rasterOperation
Windows ROP code for display. This parameter takes the same codes as the Windows BitBlt method. For ordinary painting, use SRCCOPY.
progressCallback
Callback method that will be called when the Effect is started to determine the status for the effect.

Example

This example shows how to use DrawEffect(Graphics,Point,Graphics,Rectangle,SpecialEffectsType,Int32,Int32,Int32,Int32,Int32,Int32,Boolean,Color,Int32,Color,Int32,SpecialEffectsProgress) with wave effect .

Visual BasicCopy Code
Public Sub DrawEffect(ByVal g As Graphics, ByVal destRect As Rectangle)
      Dim codecs As RasterCodecs = New RasterCodecs()
      Dim rasterImage As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"))

      Dim image As Image = RasterImageConverter.ConvertToImage(rasterImage, ConvertToImageOptions.None)
      Dim srcGraphics As Graphics = Graphics.FromImage(image)

      Dim processor As SpecialEffectsProcessor = New SpecialEffectsProcessor()

      processor.DrawEffect(srcGraphics, New Point(0, 0), g, destRect, SpecialEffectsType.WaveTB, 1, 10, 20, 1, 3, 3, False, Color.Black, 3, Color.Red, RasterPaintProperties.SourceCopy, Nothing)

      srcGraphics.Dispose()
      image.Dispose()
      rasterImage.Dispose()

   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 DrawEffect(Graphics g, Rectangle destRect)
   {
      RasterCodecs codecs = new RasterCodecs();
      RasterImage rasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"));

      Image image = RasterImageConverter.ConvertToImage(rasterImage, ConvertToImageOptions.None);
      Graphics srcGraphics = Graphics.FromImage(image);

      SpecialEffectsProcessor processor = new SpecialEffectsProcessor();

      processor.DrawEffect(srcGraphics,
                           new Point(0, 0),
                           g,
                           destRect,
                           SpecialEffectsType.WaveTB,
                           1,                /* graining size */
                           10,               /* delay between graining steps */
                           20,               /* speed of the wave */
                           1,                /* number of cycles or repetitions */
                           3,                /* step number for the pattern brush */
                           3,                /* maximum steps for the pattern brush */
                           false,            /* do not use transparency */
                           Color.Black,      /* transparent color, black */
                           3,                /* wand width */
                           Color.Red,        /* wand color, red */
                           RasterPaintProperties.SourceCopy,
                           null);

      srcGraphics.Dispose();
      image.Dispose();
      rasterImage.Dispose();

   }

static class LEAD_VARS
{
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}

Remarks

Use this method as a replacement for the Windows BitBlt API method when you want a special painting effect.

Use the grain and delay parameters to control the speed of the display. The grain parameter controls the size of the painting increment, and delay controls the time between increments.

The wand is a solid color bar that moves during an effect. Small grain sizes produce the best wand effects. Many of the effects listed in SpecialEffectsType can have a wand.

Use the pass and maxPass parameters to paint the image in more than one pass. For example, if you want a 3-pass paint, use maxPass of 3 and paint 3 times, once with pass = 1, once with pass = 2, and once with pass = 3.

Multipass painting for the PushClass is disabled.

If the effectType parameter is from the Twirl class, White Turnover class, Turnover class, Replace class, Laser class, Fade Normal class, Fade Black and White class, Fade Color class or Wave Class, the pass and maxPass parameters have no effect.

If the effectType parameter is from the Fade Normal class, Fade Black and White class or Fade Color class, the grain parameter has no effect. However, if the effectType parameter is from the Wave class, the grain parameter contains the wave size.

If the effectType parameter is from the White Turnover class, the Turnover class or the Replace class, the wandWidth and wandColor parameters have no effect. However, if the effectType parameter is from the Fade Color class, the wandColor parameter contains the bitmap color level.

The speed and cycles parameters have effect only if the effectType parameter is from the Wave class.

For general information, refer to Implementing Special Effects.

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 2000, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7

See Also