Advertisement
PiToLoKo

ImageDrawHelper for VB.NET - By Elektro

Jan 22nd, 2014
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 63.03 KB | None | 0 0
  1.  
  2. ' ***********************************************************************
  3. ' Author   : Elektro
  4. ' Created  : 01-21-2014
  5. ' Modified : 01-21-2014
  6. ' ***********************************************************************
  7. ' <copyright file="ImageDrawHelper.vb" company="Elektro Studios">
  8. '     Copyright (c) Elektro Studios. All rights reserved.
  9. ' </copyright>
  10. ' ***********************************************************************
  11.  
  12. #Region " Public Members Summary "
  13.  
  14. ' -------
  15. ' Methods
  16. ' -------
  17. '
  18. ' Properties.Brightness
  19. ' Properties.Contrast
  20. ' Properties.Gamma
  21. ' Properties.HSL
  22. ' Properties.Hue
  23. ' Properties.Opacity
  24. '
  25. ' Effects.CameraView
  26. ' Effects.ColorSubstitution
  27. ' Effects.ConvertToBlackWhite
  28. ' Effects.ConvertToNegative
  29. ' Effects.ConvertToSepia
  30. ' Effects.Crop
  31. ' Effects.DistortCorners
  32. ' Effects.DropShadow
  33. ' Effects.Fade
  34. ' Effects.Feather
  35. ' Effects.Filmstrip
  36. ' Effects.Flip
  37. ' Effects.FocalGrayscale
  38. ' Effects.GaussianBlur
  39. ' Effects.GlassTable
  40. ' Effects.Glow
  41. ' Effects.MakeTransparent
  42. ' Effects.PerspectiveReflection
  43. ' Effects.PerspectiveView
  44. ' Effects.Pixelate
  45. ' Effects.RemoveColor
  46. ' Effects.RemoveTransparency
  47. ' Effects.Resize
  48. ' Effects.Rotate
  49. ' Effects.RoundCorners
  50. ' Effects.Scale
  51. ' Effects.Sharpen
  52. ' Effects.Silhouette
  53. ' Effects.Skew
  54. ' Effects.Solarize
  55. ' Effects.Stretch
  56. ' Effects.Tint
  57.  
  58. #End Region
  59.  
  60. #Region " Usage Examples "
  61.  
  62. ' Dim [ImageElement] As ImageElement = ImageElement.FromFile("C:\Image.png")
  63. ' Dim [TextElement] As New TextElement With {.Text = "Hello World!"}
  64.  
  65. ' ImageDrawHelper.Properties.Brightness([ImageElement], 50)
  66. ' ImageDrawHelper.Properties.Contrast([ImageElement], 50)
  67. ' ImageDrawHelper.Properties.Gamma([ImageElement], 50)
  68. ' ImageDrawHelper.Properties.HSL([ImageElement], 50, 50, 50)
  69. ' ImageDrawHelper.Properties.Hue([ImageElement], 50)
  70. ' ImageDrawHelper.Properties.Opacity([ImageElement], 50)
  71. ' ImageDrawHelper.Effects.CameraView([ImageElement], 30, 25)
  72. ' ImageDrawHelper.Effects.ColorSubstitution([ImageElement], Color.Black, Color.Fuchsia, 10)
  73. ' ImageDrawHelper.Effects.ConvertToBlackWhite([ImageElement], DitherMethod.Threshold, 53, False)
  74. ' ImageDrawHelper.Effects.ConvertToNegative([ImageElement])
  75. ' ImageDrawHelper.Effects.ConvertToSepia([ImageElement])
  76. ' ImageDrawHelper.Effects.Crop([ImageElement], 0, 10, 200, 160)
  77. ' ImageDrawHelper.Effects.DistortCorners([ImageElement], -20, -20, 200, 0, 250, 180, -30, 200)
  78. ' ImageDrawHelper.Effects.DropShadow([ImageElement], 60, Color.Lime, 270, 6, 10)
  79. ' ImageDrawHelper.Effects.Fade([ImageElement], FadeShape.Oval, FillType.Gradient, GradientShape.Path)
  80. ' ImageDrawHelper.Effects.Feather([ImageElement], 5, FeatherShape.Oval)
  81. ' ImageDrawHelper.Effects.Filmstrip([ImageElement], FilmstripOrientation.Vertical, 150, 180, 0, Color.Yellow, 5)
  82. ' ImageDrawHelper.Effects.Flip([ImageElement], FlipType.Horizontal)
  83. ' ImageDrawHelper.Effects.FocalGrayscale([ImageElement], FocalShape.Oval, FillType.Gradient, GradientShape.Path, Color.FromArgb(0, 255, 255, 255), Color.FromArgb(0, 0, 0))
  84. ' ImageDrawHelper.Effects.GaussianBlur([ImageElement], 5)
  85. ' ImageDrawHelper.Effects.GlassTable([ImageElement], 50, 25)
  86. ' ImageDrawHelper.Effects.GlassTable([ImageElement], 50, 25, ReflectionLocation.Custom, 2, 10)
  87. ' ImageDrawHelper.Effects.Glow([ImageElement], Color.Red, 80, 8)
  88. ' ImageDrawHelper.Effects.MakeTransparent([ImageElement])
  89. ' ImageDrawHelper.Effects.PerspectiveReflection([ImageElement], 270, 50, 50, 150, 0)
  90. ' ImageDrawHelper.Effects.PerspectiveView([ImageElement], 25, PerspectiveOrientation.LeftToRight)
  91. ' ImageDrawHelper.Effects.Pixelate([ImageElement], 20, 0)
  92. ' ImageDrawHelper.Effects.RemoveColor([ImageElement], Color.White, 10, ScanDirection.All)
  93. ' ImageDrawHelper.Effects.RemoveTransparency([ImageElement])
  94. ' ImageDrawHelper.Effects.Resize([ImageElement], 256, 256, LockAspectRatio.WidthBased, Drawing2D.InterpolationMode.Bicubic)
  95. ' ImageDrawHelper.Effects.Rotate([ImageElement], 90, Drawing2D.InterpolationMode.Bicubic)
  96. ' ImageDrawHelper.Effects.RoundCorners([ImageElement], Corners.All, 120)
  97. ' ImageDrawHelper.Effects.RoundCorners([ImageElement], Corners.All, 20, 10, Color.Red)
  98. ' ImageDrawHelper.Effects.Scale([ImageElement], 50, 50, Drawing2D.InterpolationMode.Bicubic)
  99. ' ImageDrawHelper.Effects.Sharpen([ImageElement])
  100. ' ImageDrawHelper.Effects.Silhouette([ImageElement], Color.RoyalBlue)
  101. ' ImageDrawHelper.Effects.Skew([ImageElement], SkewType.Parallelogram, -10, SkewOrientation.Horizontal, True)
  102. ' ImageDrawHelper.Effects.Solarize([ImageElement])
  103. ' ImageDrawHelper.Effects.Stretch([ImageElement], 90, 150)
  104. ' ImageDrawHelper.Effects.Tint([ImageElement], Color.Orange)
  105.  
  106. ' PictureBox1.BackgroundImage = [ImageElement].GetOutputImage
  107.  
  108. #End Region
  109.  
  110. #Region " Imports "
  111.  
  112. Imports Neodynamic.SDK.ImageDraw
  113.  
  114. #End Region
  115.  
  116. #Region " ImageDraw Helper "
  117.  
  118. Public Class ImageDrawHelper
  119.  
  120. #Region " Public Methods "
  121.  
  122.     ''' <summary>
  123.     ''' Adjusts the properties of an Image Draw Element.
  124.     ''' </summary>
  125.     Public Class Properties
  126.  
  127.         ''' <summary>
  128.         ''' Adjusts the brightness level of an image.
  129.         ''' </summary>
  130.         ''' <param name="ImageElement">
  131.         ''' Indicates the image draw element.
  132.         ''' </param>
  133.         ''' <param name="BrightnessLevel">
  134.         ''' Indicates the brightness level.
  135.         ''' Values range from -100 to 100.
  136.         ''' </param>
  137.         Public Shared Sub Brightness(ByRef [ImageElement] As ImageElement,
  138.                                      ByVal BrightnessLevel As Integer)
  139.  
  140.             ' Create an instance of AdjustBrightness class.
  141.             Dim Action As New AdjustBrightness()
  142.  
  143.             With Action
  144.  
  145.                 ' Set the Brightness Level.
  146.                 .Level = BrightnessLevel
  147.  
  148.             End With
  149.  
  150.             ' Apply the action on the ImageElement.
  151.             [ImageElement].Actions.Add(Action)
  152.  
  153.         End Sub
  154.  
  155.         ''' <summary>
  156.         ''' Adjusts the Contrast level of an image.
  157.         ''' </summary>
  158.         ''' <param name="ImageElement">
  159.         ''' Indicates the image draw element.
  160.         ''' </param>
  161.         ''' <param name="ContrastLevel">
  162.         ''' Indicates the Contrast level.
  163.         ''' Values range from -100 to 100.
  164.         ''' </param>
  165.         Public Shared Sub Contrast(ByRef [ImageElement] As ImageElement,
  166.                              ByVal ContrastLevel As Integer)
  167.  
  168.             ' Create an instance of AdjustContrast class.
  169.             Dim Action As New AdjustContrast
  170.  
  171.             With Action
  172.  
  173.                 ' Set the Contrast Level.
  174.                 .Level = ContrastLevel
  175.  
  176.             End With
  177.  
  178.             ' Apply the action on the ImageElement.
  179.             [ImageElement].Actions.Add(Action)
  180.  
  181.         End Sub
  182.  
  183.         ''' <summary>
  184.         ''' Adjusts the gamma correction value of an image.
  185.         ''' </summary>
  186.         ''' <param name="ImageElement">
  187.         ''' Indicates the image draw element.
  188.         ''' </param>
  189.         ''' <param name="GammaCorrectionValue">
  190.         ''' Indicates the Gamma Correction value.
  191.         ''' Values range from -100 to 100.
  192.         ''' </param>
  193.         Public Shared Sub Gamma(ByRef [ImageElement] As ImageElement,
  194.                                 ByVal GammaCorrectionValue As Integer)
  195.  
  196.             ' Create an instance of AdjustGamma class.
  197.             Dim Action As New AdjustGamma
  198.  
  199.             With Action
  200.  
  201.                 ' Set the Gamma Correction value.
  202.                 .Gamma = GammaCorrectionValue
  203.  
  204.             End With
  205.  
  206.             ' Apply the action on the ImageElement.
  207.             [ImageElement].Actions.Add(Action)
  208.  
  209.         End Sub
  210.  
  211.         ''' <summary>
  212.         ''' Adjusts the HUE channel of an image.
  213.         ''' </summary>
  214.         ''' <param name="ImageElement">
  215.         ''' Indicates the image draw element.
  216.         ''' </param>
  217.         ''' <param name="HUEAngle">
  218.         ''' Indicates the HUE Angle.
  219.         ''' Values range from -180 to 180.
  220.         ''' </param>
  221.         Public Shared Sub Hue(ByRef [ImageElement] As ImageElement,
  222.                               ByVal HUEAngle As Integer)
  223.  
  224.             ' Create an instance of AdjustGamma class.
  225.             Dim Action As New AdjustHue
  226.  
  227.             With Action
  228.  
  229.                 ' Set the HUE Angle.
  230.                 .Angle = HUEAngle
  231.  
  232.             End With
  233.  
  234.             ' Apply the action on the ImageElement.
  235.             [ImageElement].Actions.Add(Action)
  236.  
  237.         End Sub
  238.  
  239.         ''' <summary>
  240.         ''' Adjusts the Hue channel, saturation, and lightness levels of an image.
  241.         ''' </summary>
  242.         ''' <param name="ImageElement">
  243.         ''' Indicates the image draw element.
  244.         ''' </param>
  245.         ''' <param name="HUEAngle">
  246.         ''' Indicates the HUE Angle.
  247.         ''' Values range from -180 to 180.
  248.         ''' </param>
  249.         ''' <param name="LightnessLevel">
  250.         ''' Indicates the Lightness level.
  251.         ''' Values range from -100 to 100.
  252.         ''' </param>
  253.         ''' <param name="SaturationLevel">
  254.         ''' Indicates the Saturation level.
  255.         ''' Values range from -100 to 100.
  256.         ''' </param>
  257.         Public Shared Sub HSL(ByRef [ImageElement] As ImageElement,
  258.                               ByVal HUEAngle As Integer,
  259.                               ByVal LightnessLevel As Integer,
  260.                               ByVal SaturationLevel As Integer)
  261.  
  262.             ' Create an instance of AdjustGamma class.
  263.             Dim Action As New AdjustHSL
  264.  
  265.             With Action
  266.  
  267.                 ' Set the HUE Angle.
  268.                 .Hue = HUEAngle
  269.  
  270.                 ' Set the Lightness Level.
  271.                 .Lightness = LightnessLevel
  272.  
  273.                 ' Set the Saturation Level.
  274.                 .Saturation = SaturationLevel
  275.  
  276.             End With
  277.  
  278.             ' Apply the action on the ImageElement.
  279.             [ImageElement].Actions.Add(Action)
  280.  
  281.         End Sub
  282.  
  283.         ''' <summary>
  284.         ''' Adjusts the opacity level of an image.
  285.         ''' </summary>
  286.         ''' <param name="ImageElement">
  287.         ''' Indicates the image draw element.
  288.         ''' </param>
  289.         ''' <param name="OpacityLevel">
  290.         ''' Indicates the Opacity Level.
  291.         ''' Values range from 0 to 100.
  292.         ''' </param>
  293.         Public Shared Sub Opacity(ByRef [ImageElement] As ImageElement,
  294.                                   ByVal OpacityLevel As Integer)
  295.  
  296.             ' Create an instance of AdjustGamma class.
  297.             Dim Action As New AdjustOpacity
  298.  
  299.             With Action
  300.  
  301.                 ' Set the Opacity Level.
  302.                 .Opacity = OpacityLevel
  303.  
  304.             End With
  305.  
  306.             ' Apply the action on the ImageElement.
  307.             [ImageElement].Actions.Add(Action)
  308.  
  309.         End Sub
  310.  
  311.     End Class
  312.  
  313.     ''' <summary>
  314.     ''' Perform some Effects to an Image Draw Element.
  315.     ''' </summary>
  316.     Public Class Effects
  317.  
  318.         ''' <summary>
  319.         ''' Simulates the camera view on an element.
  320.         ''' </summary>
  321.         ''' <param name="ImageElement">
  322.         ''' Indicates the image draw element.
  323.         ''' </param>
  324.         ''' <param name="VerticalRotationAngle">
  325.         ''' Indicates the vertical rotation angle of a camera's sight line relative
  326.         ''' to the center point of an element.
  327.         ''' Value range from -180 to 180.
  328.         ''' </param>
  329.         ''' <param name="HorizontalRotationAngle">
  330.         ''' Indicates the horizontal rotation angle of a camera's sight line relative
  331.         ''' to the center point of an element.
  332.         ''' Value range from -180 to 180.
  333.         ''' </param>
  334.         Public Shared Sub CameraView(ByRef [ImageElement] As ImageElement,
  335.                                      ByVal VerticalRotationAngle As Integer,
  336.                                      ByVal HorizontalRotationAngle As Integer)
  337.  
  338.             ' Create an instance of CameraView class.
  339.             Dim Action As New CameraView()
  340.  
  341.             With Action
  342.  
  343.                 ' Set the vertical rotation angle of a camera's sight line relative to the center point of an element.
  344.                 .Elevation = VerticalRotationAngle
  345.  
  346.                 ' Set the horizontal rotation angle of a camera's sight line relative to the center point of an element.
  347.                 .Azimuth = HorizontalRotationAngle
  348.  
  349.             End With
  350.  
  351.             ' Apply the action on the ImageElement.
  352.             [ImageElement].Actions.Add(Action)
  353.  
  354.         End Sub
  355.  
  356.         ''' <summary>
  357.         ''' Converts an element to black/white or monochrome.
  358.         ''' </summary>
  359.         ''' <param name="ImageElement">
  360.         ''' Indicates the image draw element.
  361.         ''' </param>
  362.         ''' <param name="DitherMethod">
  363.         ''' Indicates the dithering method to be used for Black/White conversion.
  364.         ''' </param>
  365.         ''' <param name="Threshold">
  366.         ''' Indicates the threshold percentage.
  367.         ''' Value range from 0 to 100.
  368.         ''' </param>
  369.         ''' <param name="ReverseEffect">
  370.         ''' Indicates whether black/white effect should be reversed.
  371.         ''' </param>
  372.         Public Shared Sub ConvertToBlackWhite(ByRef [ImageElement] As ImageElement,
  373.                                               ByVal DitherMethod As DitherMethod,
  374.                                               ByVal Threshold As Integer,
  375.                                               ByVal ReverseEffect As Boolean)
  376.  
  377.             ' Create an instance of ConvertToBlackWhite class.
  378.             Dim Action As New ConvertToBlackWhite()
  379.  
  380.             With Action
  381.  
  382.                 ' Set the dithering method to be used for Black/White conversion.
  383.                 .DitherMethod = DitherMethod
  384.  
  385.                 ' Set the threshold percentage.
  386.                 .Threshold = Threshold
  387.  
  388.                 ' Set whether black/white effect should be reversed.
  389.                 .ReverseEffect = ReverseEffect
  390.  
  391.             End With
  392.  
  393.             ' Apply the action on the ImageElement.
  394.             [ImageElement].Actions.Add(Action)
  395.  
  396.         End Sub
  397.  
  398.         ''' <summary>
  399.         ''' Converts an element to grayscale.
  400.         ''' </summary>
  401.         ''' <param name="ImageElement">
  402.         ''' Indicates the image draw element.
  403.         ''' </param>
  404.         Public Shared Sub ConvertToGrayscale(ByRef [ImageElement] As ImageElement)
  405.  
  406.             ' Create an instance of ConvertToGrayscale class.
  407.             Dim Action As New ConvertToGrayscale
  408.  
  409.             ' Apply the action on the ImageElement.
  410.             [ImageElement].Actions.Add(Action)
  411.  
  412.         End Sub
  413.  
  414.         ''' <summary>
  415.         ''' Converts an element to negative.
  416.         ''' </summary>
  417.         ''' <param name="ImageElement">
  418.         ''' Indicates the image draw element.
  419.         ''' </param>
  420.         Public Shared Sub ConvertToNegative(ByRef [ImageElement] As ImageElement)
  421.  
  422.             ' Create an instance of ConvertToNegative class.
  423.             Dim Action As New ConvertToNegative
  424.  
  425.             ' Apply the action on the ImageElement.
  426.             [ImageElement].Actions.Add(Action)
  427.  
  428.         End Sub
  429.  
  430.         ''' <summary>
  431.         ''' Converts an element to sepia.
  432.         ''' </summary>
  433.         ''' <param name="ImageElement">
  434.         ''' Indicates the image draw element.
  435.         ''' </param>
  436.         Public Shared Sub ConvertToSepia(ByRef [ImageElement] As ImageElement)
  437.  
  438.             ' Create an instance of ConvertToSepia class.
  439.             Dim Action As New ConvertToSepia
  440.  
  441.             ' Apply the action on the ImageElement.
  442.             [ImageElement].Actions.Add(Action)
  443.  
  444.         End Sub
  445.  
  446.         ''' <summary>
  447.         ''' Replaces one color (old color) with another (new color) on an element.
  448.         ''' </summary>
  449.         ''' <param name="ImageElement">
  450.         ''' Indicates the image draw element.
  451.         ''' </param>
  452.         ''' <param name="OldColor">
  453.         ''' Indicates the old color to be replaced on the target element.
  454.         ''' </param>
  455.         ''' <param name="Newcolor">
  456.         ''' Indicates the new color to replace the old color on the target element.
  457.         ''' </param>
  458.         ''' <param name="ColorTolerance">
  459.         ''' Indicates the color tolerance for replacing pixels.
  460.         ''' Color Tolerance represents the tonal range of colors that will be replaced by taking
  461.         ''' the specified color as starting point.
  462.         ''' If you enter 0, only adjacent pixels of exactly the same tone as the specified color will be replaced;
  463.         ''' otherwise, a wider range of tones will be replaced
  464.         ''' </param>
  465.         Public Shared Sub ColorSubstitution(ByRef [ImageElement] As ImageElement,
  466.                                             ByVal OldColor As Color,
  467.                                             ByVal Newcolor As Color,
  468.                                             ByVal ColorTolerance As Byte)
  469.  
  470.             ' Create an instance of ColorSubstitution class
  471.             Dim Action As New ColorSubstitution()
  472.  
  473.             With Action
  474.  
  475.                 ' Set the old color to be replaced on the target element.
  476.                 .OldColor = OldColor
  477.  
  478.                 ' Set the color tolerance for replacing pixels.
  479.                 .ColorTolerance = ColorTolerance
  480.  
  481.                 ' Set the new color to replace the old color on the target element.
  482.                 .NewColor = Newcolor
  483.  
  484.             End With
  485.  
  486.             ' Apply the action on the ImageElement.
  487.             [ImageElement].Actions.Add(Action)
  488.  
  489.         End Sub
  490.  
  491.         ''' <summary>
  492.         ''' Crops a rectangular section from an image.
  493.         ''' </summary>
  494.         ''' <param name="ImageElement">
  495.         ''' Indicates the image draw element.
  496.         ''' </param>
  497.         ''' <param name="X">
  498.         ''' Indicates the X-coordinate of the cropping rectangle.
  499.         ''' </param>
  500.         ''' <param name="Y">
  501.         ''' Indicates the Y-coordinate of the cropping rectangle.</param>
  502.         ''' <param name="Width">
  503.         ''' Indicates the Width of the cropping rectangle.
  504.         ''' </param>
  505.         ''' <param name="Height">
  506.         ''' Indicates the Height of the cropping rectangle.
  507.         ''' </param>
  508.         Public Shared Sub Crop(ByRef [ImageElement] As ImageElement,
  509.                                ByVal X As Integer,
  510.                                ByVal Y As Integer,
  511.                                ByVal Width As Integer,
  512.                                ByVal Height As Integer)
  513.  
  514.             ' Create an instance of Crop class.
  515.             Dim Action As New Crop()
  516.  
  517.             With Action
  518.  
  519.                 ' Set the X-coordinate of the cropping rectangle.
  520.                 .X = X
  521.  
  522.                 ' Set the Y-coordinate of the cropping rectangle.
  523.                 .Y = Y
  524.  
  525.                 ' Set the Width of the cropping rectangle.
  526.                 .Width = Width
  527.  
  528.                 ' Set the Height of the cropping rectangle.
  529.                 .Height = Height
  530.  
  531.             End With
  532.  
  533.             ' Apply the action on the ImageElement.
  534.             [ImageElement].Actions.Add(Action)
  535.  
  536.         End Sub
  537.  
  538.         ''' <summary>
  539.         ''' Distorts an element by changing the coordinates of the four corners defined by the element's boundaries.
  540.         ''' </summary>
  541.         ''' <param name="ImageElement">
  542.         ''' Indicates the image draw element.
  543.         ''' </param>
  544.         ''' <param name="X1">
  545.         ''' Indicates the new upper-left corner x-coordinate.
  546.         ''' </param>
  547.         ''' <param name="Y1">
  548.         ''' Indicates the new upper-left corner y-coordinate.
  549.         ''' </param>
  550.         ''' <param name="X2">
  551.         ''' Indicates the upper-right corner x-coordinate.
  552.         ''' </param>
  553.         ''' <param name="Y2">
  554.         ''' Indicates the upper-right corner y-coordinate.
  555.         ''' </param>
  556.         ''' <param name="X3">
  557.         ''' Indicates the new bottom-right corner x-coordinate.
  558.         ''' </param>
  559.         ''' <param name="Y3">
  560.         ''' Indicates the new bottom-right corner y-coordinate.
  561.         ''' </param>
  562.         ''' <param name="X4">
  563.         ''' Indicates the new bottom-left corner x-coordinate.
  564.         ''' </param>
  565.         ''' <param name="Y4">
  566.         ''' Indicates the new bottom-left corner y-coordinate.
  567.         ''' </param>
  568.         Public Shared Sub DistortCorners(ByRef [ImageElement] As ImageElement,
  569.                                          ByVal X1 As Integer, ByVal Y1 As Integer,
  570.                                          ByVal X2 As Integer, ByVal Y2 As Integer,
  571.                                          ByVal X3 As Integer, ByVal Y3 As Integer,
  572.                                          ByVal X4 As Integer, ByVal Y4 As Integer)
  573.  
  574.             ' Create an instance of DistortCorners class.
  575.             Dim Action As New DistortCorners()
  576.  
  577.             With Action
  578.  
  579.                 ' Set the new upper-left corner X,Y coordinates.
  580.                 .X1 = X1 : .Y1 = Y1
  581.  
  582.                 ' Set the new upper-right corner X,Y coordinates.
  583.                 .X2 = X2 : .Y2 = Y2
  584.  
  585.                 ' Set the new bottom-right corner X,Y coordinates.
  586.                 .X3 = X3 : .Y3 = Y3
  587.  
  588.                 ' Set the new bottom-left corner X,Y coordinates.
  589.                 .X4 = X4 : .Y4 = Y4
  590.  
  591.             End With
  592.  
  593.             ' Apply the action on the ImageElement.
  594.             [ImageElement].Actions.Add(Action)
  595.  
  596.         End Sub
  597.  
  598.         ''' <summary>
  599.         ''' Adds drop shadows to an image.
  600.         ''' </summary>
  601.         ''' <param name="ImageElement">
  602.         ''' Indicates the image draw element.
  603.         ''' </param>
  604.         ''' <param name="Opacity">
  605.         ''' Indicates the percentage of transparency in the shadow.
  606.         ''' Value from 0 to 100.
  607.         ''' </param>
  608.         ''' <param name="ShadowColor">
  609.         ''' Indicates the color of the shadow.
  610.         ''' </param>
  611.         ''' <param name="ShadowAngle">
  612.         ''' Indicates the direction of the shadow.
  613.         ''' </param>
  614.         ''' <param name="ShadowDistance">
  615.         ''' Indicates the distance of the shadow from the object.
  616.         ''' </param>
  617.         ''' <param name="ShadowSoftness">
  618.         ''' Indicates the sharpness of the shadow.
  619.         ''' </param>
  620.         Public Shared Sub DropShadow(ByRef [ImageElement] As ImageElement,
  621.                                      ByVal Opacity As Integer,
  622.                                      ByVal ShadowColor As Color,
  623.                                      ByVal ShadowAngle As Integer,
  624.                                      ByVal ShadowDistance As Integer,
  625.                                      ByVal ShadowSoftness As Integer)
  626.  
  627.             ' Create an instance of DropShadow class.
  628.             Dim Action As New DropShadow
  629.  
  630.             With Action
  631.  
  632.                 ' Set the percentage of transparency in the shadow.
  633.                 .Opacity = Opacity
  634.  
  635.                 ' Set the color of the shadow.
  636.                 .Color = ShadowColor
  637.  
  638.                 ' Set the direction of the shadow.
  639.                 .Angle = ShadowAngle
  640.  
  641.                 ' Set the distance of the shadow from the object.
  642.                 .Distance = ShadowDistance
  643.  
  644.                 ' Set the sharpness of the shadow.
  645.                 .Softness = ShadowSoftness
  646.  
  647.             End With
  648.  
  649.             ' Apply the action on the ImageElement.
  650.             [ImageElement].Actions.Add(Action)
  651.  
  652.         End Sub
  653.  
  654.         ''' <summary>
  655.         ''' Performs fading.
  656.         ''' Fading action/effect gradually fades a given area/region of the target Element into the background.
  657.         ''' </summary>
  658.         ''' <param name="ImageElement">
  659.         ''' Indicates the image draw element.
  660.         ''' </param>
  661.         ''' <param name="FadeShape">
  662.         ''' Indicates the the area/region's shape used for fading.
  663.         ''' </param>
  664.         ''' <param name="FillType">
  665.         ''' Indicates the fill type.
  666.         ''' </param>
  667.         ''' <param name="GradientShape">
  668.         ''' Indicates the shape used for creating gradient fills.
  669.         ''' </param>
  670.         ''' <param name="Location">
  671.         ''' Indicates how the area/region's shape used for fading will be positioned.
  672.         ''' If it is FadeLocation.Center, then the area/region will be centered on the target Element;
  673.         ''' otherwise, the area/region's location must be specified by LocationX and LocationY properties.
  674.         ''' </param>
  675.         ''' <param name="LocationX">
  676.         ''' Indicates the x-coordinate of the top side of the fading shape area/region.
  677.         ''' </param>
  678.         ''' <param name="LocationY">
  679.         ''' Indicates the y-coordinate of the top side of the fading shape area/region.
  680.         ''' </param>
  681.         ''' <param name="Sizing">
  682.         ''' Indicates the area/region's size type used for fading.
  683.         ''' If it is FadeSizing.Fit, then the area/region's size will automatically fit to the target Element's size;
  684.         ''' otherwise, the area/region's size must be specified by SizingWidth and SizingHeight properties.
  685.         ''' </param>
  686.         ''' <param name="SizingHeight">
  687.         ''' Indicates the height of the fading shape area/region.
  688.         ''' </param>
  689.         ''' <param name="SizingWidth">
  690.         ''' Indicates the width of the fading shape area/region.
  691.         ''' </param>
  692.         Public Shared Sub Fade(ByRef [ImageElement] As ImageElement,
  693.                                ByVal FadeShape As FadeShape,
  694.                                ByVal FillType As FillType,
  695.                                ByVal GradientShape As GradientShape,
  696.                                Optional ByVal Location As FadeLocation = FadeLocation.Center,
  697.                                Optional ByVal LocationX As Integer = 1,
  698.                                Optional ByVal LocationY As Integer = 1,
  699.                                Optional ByVal Sizing As FadeSizing = FadeSizing.Fit,
  700.                                Optional ByVal SizingHeight As Integer = 1,
  701.                                Optional ByVal SizingWidth As Integer = 1)
  702.  
  703.             ' Create an instance of Fade class
  704.             Dim Action As New Fade()
  705.  
  706.             With Action
  707.  
  708.                 ' Set the the area/region's shape used for fading.
  709.                 .Shape = FadeShape
  710.  
  711.                 ' Set the fill type.
  712.                 .ShapeFill.Type = FillType
  713.  
  714.                 ' Set the shape used for creating gradient fills.
  715.                 .ShapeFill.GradientShape = GradientShape
  716.  
  717.                 ' Set how the area/region's shape used for fading will be positioned.
  718.                 .Location = Location
  719.  
  720.                 ' Set the x-coordinate of the left side of the fading shape area/region.
  721.                 .X = LocationX
  722.  
  723.                 ' Set the y-coordinate of the top side of the fading shape area/region.
  724.                 .Y = LocationY
  725.  
  726.                 ' Set the area/region's size type used for fading.  
  727.                 .Sizing = Sizing
  728.  
  729.                 ' Set the height of the fading shape area/region.
  730.                 .Height = SizingHeight
  731.  
  732.                 ' Set the width of the fading shape area/region.
  733.                 .Width = SizingWidth
  734.  
  735.             End With
  736.  
  737.             ' Apply the action on the ImageElement.
  738.             [ImageElement].Actions.Add(Action)
  739.  
  740.         End Sub
  741.  
  742.         ''' <summary>
  743.         ''' Performs feathering.
  744.         ''' Feathering blurs the edges of a given area/region on the target Element,
  745.         ''' blending it into the background.
  746.         ''' </summary>
  747.         ''' <param name="ImageElement">
  748.         ''' Indicates the image draw element.
  749.         ''' </param>
  750.         ''' <param name="FeatherRadius">
  751.         ''' Indicates the amount of feathering.
  752.         ''' Value range from 0 to 100.
  753.         ''' </param>
  754.         ''' <param name="FeatherShape">
  755.         ''' Indicates the area/region's shape used for feathering.
  756.         ''' </param>
  757.         Public Shared Sub Feather(ByRef [ImageElement] As ImageElement,
  758.                                   ByVal FeatherRadius As Integer,
  759.                                   ByVal FeatherShape As FeatherShape)
  760.  
  761.             ' Create an instance of Fade class
  762.             Dim Action As New Feather()
  763.  
  764.             With Action
  765.  
  766.                 ' Set the amount of feathering.
  767.                 .FeatherRadius = FeatherRadius
  768.  
  769.                 ' Set the area/region's shape used for feathering.
  770.                 .Shape = FeatherShape
  771.  
  772.             End With
  773.  
  774.             ' Apply the action on the ImageElement.
  775.             [ImageElement].Actions.Add(Action)
  776.  
  777.         End Sub
  778.  
  779.         ''' <summary>
  780.         ''' Creates a Filmstrip representation of an image.
  781.         ''' </summary>
  782.         ''' <param name="ImageElement">
  783.         ''' Indicates the image draw element.
  784.         ''' </param>
  785.         ''' <param name="Orientation">
  786.         ''' Indicates the orientation of the filmstrip.
  787.         ''' </param>
  788.         ''' <param name="Width">
  789.         ''' Indicates the width of the filmstrip.
  790.         ''' </param>
  791.         ''' <param name="Height">
  792.         ''' Indicates the height of the filmstrip.
  793.         ''' </param>
  794.         ''' <param name="Roundness">
  795.         ''' Indicates the corner roundness of the filmstrip content.
  796.         ''' </param>
  797.         ''' <param name="PerforationColor">
  798.         ''' Indicates the perforations color of the filmstrip.
  799.         ''' </param>
  800.         ''' <param name="PerforationWidth">
  801.         ''' Indicates the perforations Width of the filmstrip.
  802.         ''' </param>
  803.         Public Shared Sub Filmstrip(ByRef [ImageElement] As ImageElement,
  804.                                     ByVal Orientation As FilmstripOrientation,
  805.                                     ByVal Width As Integer,
  806.                                     ByVal Height As Integer,
  807.                                     ByVal Roundness As Integer,
  808.                                     ByVal PerforationColor As Color,
  809.                                     ByVal PerforationWidth As Integer)
  810.  
  811.             ' Create an instance of Fade class
  812.             Dim Action As New Filmstrip()
  813.  
  814.             With Action
  815.  
  816.                 ' Set the orientation of the filmstrip.
  817.                 .Orientation = Orientation
  818.  
  819.                 ' Set the width of the filmstrip.
  820.                 .Width = Width
  821.  
  822.                 ' Set the height of the filmstrip.
  823.                 .Height = Height
  824.  
  825.                 ' Set the corner roundness of the filmstrip content.
  826.                 .Roundness = Roundness
  827.  
  828.                 ' Set sets the perforations color of the filmstrip.
  829.                 .PerforationColor = PerforationColor
  830.  
  831.                 ' Set the perforations width of the filmstrip.
  832.                 .PerforationWidth = PerforationWidth
  833.  
  834.             End With
  835.  
  836.             ' Apply the action on the ImageElement.
  837.             [ImageElement].Actions.Add(Action)
  838.  
  839.         End Sub
  840.  
  841.         ''' <summary>
  842.         ''' Flips an image across its vertical or horizontal axis.
  843.         ''' </summary>
  844.         ''' <param name="ImageElement">
  845.         ''' Indicates the image draw element.
  846.         ''' </param>
  847.         ''' <param name="Direction">
  848.         ''' Indicates the direction used to flip an image.
  849.         ''' </param>
  850.         Public Shared Sub Flip(ByRef [ImageElement] As ImageElement,
  851.                                ByVal Direction As FlipType)
  852.  
  853.             ' Create an instance of Fade class
  854.             Dim Action As New Flip()
  855.  
  856.             With Action
  857.  
  858.                 ' Set the direction used to flip an image.
  859.                 .Type = Direction
  860.  
  861.             End With
  862.  
  863.             ' Apply the action on the ImageElement.
  864.             [ImageElement].Actions.Add(Action)
  865.  
  866.         End Sub
  867.  
  868.         ''' <summary>
  869.         ''' Creates grayscale element with a colored focal point represented by a shape.
  870.         ''' </summary>
  871.         ''' <param name="ImageElement">
  872.         ''' Indicates the image draw element.
  873.         ''' </param>
  874.         ''' <param name="FocalShape">
  875.         ''' Indicates the area/region's shape used for creating the colored focal point.
  876.         ''' </param>
  877.         ''' <param name="FillType">
  878.         ''' Indicates the fill type.
  879.         ''' </param>
  880.         ''' <param name="GradientShape">
  881.         ''' Indicates the shape used for creating gradient fills.
  882.         ''' </param>
  883.         ''' <param name="GradientColor1">
  884.         ''' Indicates the starting color used by Gradient fill type.
  885.         ''' </param>
  886.         ''' <param name="GradientColor2">
  887.         ''' Indicates the ending color used by Gradient fill type.
  888.         ''' </param>
  889.         ''' <param name="Location">
  890.         ''' Indicates how the area/region's shape used for creating the colored focal point will be positioned.
  891.         ''' If it is FocalLocation.Center, then the area/region will be centered on the target Element;
  892.         ''' otherwise, the area/region's location must be specified by LocationX and LocationY properties.
  893.         ''' </param>
  894.         ''' <param name="LocationX">
  895.         ''' Indicates the x-coordinate of the left side of the focal shape area/region.
  896.         ''' </param>
  897.         ''' <param name="LocationY">
  898.         ''' Indicates the y-coordinate of the left side of the focal shape area/region.
  899.         ''' </param>
  900.         ''' <param name="Sizing">
  901.         ''' Indicates the area/region's size type used for creating the colored focal point.
  902.         ''' If it is FocalSizing.Fit, then the area/region's size will automatically fit to the target Element's size;
  903.         ''' otherwise, the area/region's size must be specified by SizingWidth and SizingHeight properties.
  904.         ''' </param>
  905.         ''' <param name="SizingHeight">
  906.         ''' Indicates the height of the focal shape area/region.
  907.         ''' </param>
  908.         ''' <param name="SizingWidth">
  909.         ''' Indicates the width of the focal shape area/region.
  910.         ''' </param>
  911.         Public Shared Sub FocalGrayscale(ByRef [ImageElement] As ImageElement,
  912.                                          ByVal FocalShape As FocalShape,
  913.                                          ByVal FillType As FillType,
  914.                                          ByVal GradientShape As GradientShape,
  915.                                          ByVal GradientColor1 As Color,
  916.                                          ByVal GradientColor2 As Color,
  917.                                          Optional ByVal Location As FocalLocation = FocalLocation.Center,
  918.                                          Optional ByVal LocationX As Integer = 1,
  919.                                          Optional ByVal LocationY As Integer = 1,
  920.                                          Optional ByVal Sizing As FocalSizing = FocalSizing.Fit,
  921.                                          Optional ByVal SizingHeight As Integer = 1,
  922.                                          Optional ByVal SizingWidth As Integer = 1)
  923.  
  924.             ' Create an instance of Fade class
  925.             Dim Action As New FocalGrayscale()
  926.  
  927.             With Action
  928.  
  929.                 ' Set the area/region's shape used for creating the colored focal point.
  930.                 .Shape = FocalShape
  931.  
  932.                 ' Set the fill type.
  933.                 .ShapeFill.Type = FillType
  934.  
  935.                 ' Set the shape used for creating gradient fills.
  936.                 .ShapeFill.GradientShape = GradientShape
  937.  
  938.                 ' Set the starting color used by Gradient fill type.
  939.                 .ShapeFill.GradientColor1 = GradientColor1
  940.  
  941.                 ' Set the ending color used by Gradient fill type.
  942.                 .ShapeFill.GradientColor2 = GradientColor2
  943.  
  944.                 ' Set how the area/region's shape used for creating the colored focal point will be positioned.
  945.                 .Location = Location
  946.  
  947.                 ' Set the x-coordinate of the left side of the focal shape area/region.
  948.                 .X = LocationX
  949.  
  950.                 ' Set the y-coordinate of the left side of the focal shape area/region.
  951.                 .Y = LocationY
  952.  
  953.                 ' Set the area/region's size type used for creating the colored focal point.
  954.                 .Sizing = Sizing
  955.  
  956.                 ' Set the height of the focal shape area/region.
  957.                 .Height = SizingHeight
  958.  
  959.                 ' Set the width of the focal shape area/region.
  960.                 .Width = SizingWidth
  961.  
  962.             End With
  963.  
  964.             ' Apply the action on the ImageElement.
  965.             [ImageElement].Actions.Add(Action)
  966.  
  967.         End Sub
  968.  
  969.         ''' <summary>
  970.         ''' Softens the look of an element.
  971.         ''' Gaussian Blur applies a weighted average of blur to each pixel producing a hazy effect.
  972.         ''' </summary>
  973.         ''' <param name="ImageElement">
  974.         ''' Indicates the image draw element.
  975.         ''' </param>
  976.         ''' <param name="Radius">
  977.         ''' Indicates the strength of the blur effect.
  978.         ''' Value range from 0 to 50.
  979.         ''' </param>
  980.         Public Shared Sub GaussianBlur(ByRef [ImageElement] As ImageElement,
  981.                                        ByVal Radius As Integer)
  982.  
  983.             ' Create an instance of GaussianBlur class
  984.             Dim Action As New GaussianBlur()
  985.  
  986.             With Action
  987.  
  988.                 ' Set the strength of the blur effect.
  989.                 .Radius = Radius
  990.  
  991.             End With
  992.  
  993.             ' Apply the action on the ImageElement.
  994.             [ImageElement].Actions.Add(Action)
  995.  
  996.         End Sub
  997.  
  998.         ''' <summary>
  999.         ''' Creates a glass table effect on an image.
  1000.         ''' The glass table effect adds a reflection of an image just below it.
  1001.         ''' </summary>
  1002.         ''' <param name="ImageElement">
  1003.         ''' Indicates the image draw element.
  1004.         ''' </param>
  1005.         ''' <param name="ReflectionOpacity">
  1006.         ''' Indicates the percentage of transparency in the reflection.
  1007.         ''' Value range from 0 to 100.
  1008.         ''' </param>
  1009.         ''' <param name="ReflectionPercentage">
  1010.         ''' Indicates the percentage of the image height that will be reflected.
  1011.         ''' Value range from 0 to 100.
  1012.         ''' </param>
  1013.         ''' <param name="ReflectionLocation">
  1014.         ''' Indicates how the reflection of the image will be positioned.
  1015.         ''' If it is ReflectionLocation.Auto, then the reflection will be positioned just below of the image
  1016.         ''' based on its dimensions;
  1017.         ''' otherwise, the reflection position must be specified by ReflectionLocationX and ReflectionLocationY properties.
  1018.         ''' </param>
  1019.         ''' <param name="ReflectionLocationX">
  1020.         ''' Indicates the x-coordinate of the left side of the reflection image.
  1021.         ''' .</param>
  1022.         ''' <param name="ReflectionLocationY">
  1023.         ''' Indicates the y-coordinate of the top side of the reflection image.
  1024.         ''' </param>
  1025.         Public Shared Sub GlassTable(ByRef [ImageElement] As ImageElement,
  1026.                                      ByVal ReflectionOpacity As Integer,
  1027.                                      ByVal ReflectionPercentage As Integer,
  1028.                                      Optional ByVal ReflectionLocation As ReflectionLocation = ReflectionLocation.Auto,
  1029.                                      Optional ByVal ReflectionLocationX As Integer = 1,
  1030.                                      Optional ByVal ReflectionLocationY As Integer = 1)
  1031.  
  1032.             ' Create an instance of GlassTable class.
  1033.             Dim Action As New GlassTable()
  1034.  
  1035.             With Action
  1036.  
  1037.                 ' Set the percentage of transparency in the reflection.
  1038.                 .ReflectionOpacity = ReflectionOpacity
  1039.  
  1040.                 ' Set the percentage of the image height that will be reflected.
  1041.                 .ReflectionPercentage = ReflectionPercentage
  1042.  
  1043.                 ' Set how the reflection of the image will be positioned.
  1044.                 .ReflectionLocation = ReflectionLocation
  1045.  
  1046.                 ' Set the x-coordinate of the left side of the reflection image.
  1047.                 .ReflectionLocationX = ReflectionLocationX
  1048.  
  1049.                 ' Set the y-coordinate of the top side of the reflection image.
  1050.                 .ReflectionLocationY = ReflectionLocationY
  1051.  
  1052.             End With
  1053.  
  1054.             ' Apply the action on the ImageElement.
  1055.             [ImageElement].Actions.Add(Action)
  1056.  
  1057.         End Sub
  1058.  
  1059.         ''' <summary>
  1060.         ''' Adds glow effect to an image.
  1061.         ''' </summary>
  1062.         ''' <param name="ImageElement">
  1063.         ''' Indicates the image draw element.
  1064.         ''' </param>
  1065.         ''' <param name="GlowColor">
  1066.         ''' Indicates the Glow color.
  1067.         ''' </param>
  1068.         ''' <param name="Opacity">
  1069.         ''' Indicates the percentage of transparency in the glow.
  1070.         ''' Value range from 0 to 100.
  1071.         ''' </param>
  1072.         ''' <param name="Softness">
  1073.         ''' Indicates the sharpness of the glow.
  1074.         ''' </param>
  1075.         Public Shared Sub Glow(ByRef [ImageElement] As ImageElement,
  1076.                                ByVal GlowColor As Color,
  1077.                                ByVal Opacity As Integer,
  1078.                                ByVal Softness As Integer)
  1079.  
  1080.             ' Create an instance of Glow class.
  1081.             Dim Action As New Glow()
  1082.  
  1083.             With Action
  1084.  
  1085.                 ' Set the Glow color.
  1086.                 .Color = GlowColor
  1087.  
  1088.                 ' Set the percentage of transparency in the glow.
  1089.                 .Opacity = Opacity
  1090.  
  1091.                 ' Set the sharpness of the glow.
  1092.                 .Softness = Softness
  1093.  
  1094.             End With
  1095.  
  1096.             ' Apply the action on the ImageElement.
  1097.             [ImageElement].Actions.Add(Action)
  1098.  
  1099.         End Sub
  1100.  
  1101.         ''' <summary>
  1102.         ''' Makes transparent color for an image.
  1103.         ''' </summary>
  1104.         ''' <param name="ImageElement">
  1105.         ''' Indicates the image draw element.
  1106.         ''' </param>
  1107.         Public Shared Sub MakeTransparent(ByRef [ImageElement] As ImageElement)
  1108.  
  1109.             ' Create an instance of MakeTransparent class
  1110.             Dim Action As New MakeTransparent()
  1111.  
  1112.             With Action
  1113.  
  1114.                 ' Set whether the first pixel color of an image will be used as the transparent color.
  1115.                 .UseFirstPixel = True
  1116.  
  1117.             End With
  1118.  
  1119.             ' Apply the action on the ImageElement.
  1120.             [ImageElement].Actions.Add(Action)
  1121.  
  1122.         End Sub
  1123.  
  1124.         ''' <summary>
  1125.         ''' Makes transparent color for an image.
  1126.         ''' </summary>
  1127.         ''' <param name="ImageElement">
  1128.         ''' Indicates the image draw element.
  1129.         ''' </param>
  1130.         ''' <param name="Color">
  1131.         ''' Indicates the transparent color.
  1132.         ''' </param>
  1133.         ''' <param name="ColorTolerance">
  1134.         ''' Indicates the color tolerance for transparency.
  1135.         ''' Color Tolerance represents the tonal range of colors that will be converted to
  1136.         ''' transparent taking the specified color as starting point.
  1137.         ''' If you enter 0, only adjacent pixels of exactly the same tone as the specified color will be
  1138.         ''' converted to transparent;
  1139.         ''' otherwise, a wider range of tones will be converted.
  1140.         ''' </param>
  1141.         ''' <param name="ScanDirection">
  1142.         ''' Indicates the direction of the pixel scanning process.
  1143.         ''' </param>
  1144.         Public Shared Sub MakeTransparent(ByRef [ImageElement] As ImageElement,
  1145.                                           ByVal Color As Color,
  1146.                                           ByVal ColorTolerance As Byte,
  1147.                                           ByVal ScanDirection As ScanDirection)
  1148.  
  1149.             ' Create an instance of MakeTransparent class
  1150.             Dim Action As New MakeTransparent()
  1151.  
  1152.             With Action
  1153.  
  1154.                 ' Set whether the first pixel color of an image will be used as the transparent color.
  1155.                 .UseFirstPixel = False
  1156.  
  1157.                 ' Set the transparent color.
  1158.                 .Color = Color
  1159.  
  1160.                 ' Set the color tolerance for transparency.
  1161.                 .ColorTolerance = ColorTolerance
  1162.  
  1163.                 ' Set the direction of the pixel scanning process.
  1164.                 .ScanDirection = ScanDirection
  1165.  
  1166.             End With
  1167.  
  1168.             ' Apply the action on the ImageElement.
  1169.             [ImageElement].Actions.Add(Action)
  1170.  
  1171.         End Sub
  1172.  
  1173.         ''' <summary>
  1174.         ''' Adds perspective reflection to an element.
  1175.         ''' </summary>
  1176.         ''' <param name="ImageElement">
  1177.         ''' Indicates the image draw element.
  1178.         ''' </param>
  1179.         ''' <param name="Angle">
  1180.         ''' Indicates the direction of the perspective reflection.
  1181.         ''' Value range from 0 to 360.
  1182.         ''' </param>
  1183.         ''' <param name="Opacity">
  1184.         ''' Indicates the percentage of transparency in the reflection.
  1185.         ''' </param>
  1186.         ''' <param name="Length">
  1187.         ''' Indicates the length of the perspective reflection.
  1188.         ''' </param>
  1189.         ''' <param name="WidthPercentage">
  1190.         ''' Indicates the width percentage of the perspective reflection based on the element's width.
  1191.         ''' </param>
  1192.         ''' <param name="OffsetY">
  1193.         ''' Indicates the Y-axis offset value for the perspective reflection.
  1194.         ''' </param>
  1195.         Public Shared Sub PerspectiveReflection(ByRef [ImageElement] As ImageElement,
  1196.                                             ByVal Angle As Integer,
  1197.                                             ByVal Opacity As Integer,
  1198.                                             ByVal Length As Integer,
  1199.                                             ByVal WidthPercentage As Integer,
  1200.                                             ByVal OffsetY As Integer)
  1201.  
  1202.             ' Create an instance of PerspectiveView class
  1203.             Dim Action As New PerspectiveReflection()
  1204.  
  1205.             With Action
  1206.  
  1207.  
  1208.                 ' Set the direction of the perspective reflection.
  1209.                 .Angle = Angle
  1210.  
  1211.                 ' Set the percentage of transparency in the reflection.
  1212.                 .Opacity = Opacity
  1213.  
  1214.                 ' Set the length of the perspective reflection.
  1215.                 .Length = Length
  1216.  
  1217.                 ' Set the width percentage of the perspective reflection based on the element's width.
  1218.                 .WidthPercentage = WidthPercentage
  1219.  
  1220.                 ' Set the Y-axis offset value for the perspective reflection.
  1221.                 .OffsetY = OffsetY
  1222.  
  1223.             End With
  1224.  
  1225.             ' Apply the action on the ImageElement.
  1226.             [ImageElement].Actions.Add(Action)
  1227.  
  1228.         End Sub
  1229.  
  1230.         ''' <summary>
  1231.         ''' Simulates a perspective view of an element.
  1232.         ''' </summary>
  1233.         ''' <param name="ImageElement">
  1234.         ''' Indicates the image draw element.
  1235.         ''' </param>
  1236.         ''' <param name="Angle">
  1237.         ''' Indicates the.
  1238.         ''' Value range from 0 to 90.
  1239.         ''' </param>
  1240.         ''' <param name="Orientation">
  1241.         ''' Indicates the perspective view orientation.
  1242.         ''' </param>
  1243.         Public Shared Sub PerspectiveView(ByRef [ImageElement] As ImageElement,
  1244.                                           ByVal Angle As Integer,
  1245.                                           ByVal Orientation As PerspectiveOrientation)
  1246.  
  1247.             ' Create an instance of PerspectiveView class
  1248.             Dim Action As New PerspectiveView()
  1249.  
  1250.             With Action
  1251.  
  1252.                 ' Set the perspective view angle.
  1253.                 .Angle = Angle
  1254.  
  1255.                 ' Set the perspective view orientation.
  1256.                 .Orientation = Orientation
  1257.  
  1258.             End With
  1259.  
  1260.             ' Apply the action on the ImageElement.
  1261.             [ImageElement].Actions.Add(Action)
  1262.  
  1263.         End Sub
  1264.  
  1265.         ''' <summary>
  1266.         ''' Pixelates an element.
  1267.         ''' </summary>
  1268.         ''' <param name="ImageElement">
  1269.         ''' Indicates the image draw element.
  1270.         ''' </param>
  1271.         ''' <param name="PixelSize">
  1272.         ''' Indicates the pixel size.
  1273.         ''' </param>
  1274.         ''' <param name="FadePercent">
  1275.         ''' Indicates the fade percentage.
  1276.         ''' Value range from 0 to 100.
  1277.         ''' </param>
  1278.         Public Shared Sub Pixelate(ByRef [ImageElement] As ImageElement,
  1279.                                    ByVal PixelSize As Integer,
  1280.                                    ByVal FadePercent As Integer)
  1281.  
  1282.             ' Create an instance of Pixelate class
  1283.             Dim Action As New Pixelate()
  1284.  
  1285.             With Action
  1286.  
  1287.                 ' Set the pixel size.
  1288.                 .PixelSize = PixelSize
  1289.  
  1290.                 ' Set the fade percentage.
  1291.                 .Fade = FadePercent
  1292.  
  1293.             End With
  1294.  
  1295.             ' Apply the action on the ImageElement.
  1296.             [ImageElement].Actions.Add(Action)
  1297.  
  1298.         End Sub
  1299.  
  1300.         ''' <summary>
  1301.         ''' Removes a color from an element and automatically resizes it.
  1302.         ''' </summary>
  1303.         ''' <param name="ImageElement">
  1304.         ''' Indicates the image draw element.
  1305.         ''' </param>
  1306.         ''' <param name="Color">
  1307.         ''' Indicates the color to be removed from the target element.
  1308.         ''' </param>
  1309.         ''' <param name="ColorTolerance">
  1310.         ''' Indicates the color tolerance for removing pixels.
  1311.         ''' Color Tolerance represents the tonal range of colors that will be removed taking
  1312.         ''' the specified color as starting point.
  1313.         ''' If you enter 0, only adjacent pixels of exactly the same tone as the specified color will be removed;
  1314.         ''' otherwise, a wider range of tones will be removed.
  1315.         ''' </param>
  1316.         ''' <param name="ScanDirection">
  1317.         ''' Indicates the direction of the pixel scanning process.
  1318.         ''' </param>
  1319.         Public Shared Sub RemoveColor(ByRef [ImageElement] As ImageElement,
  1320.                                       ByVal Color As Color,
  1321.                                       ByVal ColorTolerance As Byte,
  1322.                                       ByVal ScanDirection As ScanDirection)
  1323.  
  1324.             ' Create an instance of RemovePixel class
  1325.             Dim Action As New RemovePixel()
  1326.  
  1327.             With Action
  1328.  
  1329.                 ' Set the color to be removed from the target element.
  1330.                 .Color = Color
  1331.  
  1332.                 ' Set the color tolerance for removing pixels.
  1333.                 .ColorTolerance = ColorTolerance
  1334.  
  1335.                 ' Set the direction of the pixel scanning process.
  1336.                 .ScanDirection = ScanDirection
  1337.  
  1338.             End With
  1339.  
  1340.             ' Apply the action on the ImageElement.
  1341.             [ImageElement].Actions.Add(Action)
  1342.  
  1343.         End Sub
  1344.  
  1345.         ''' <summary>
  1346.         ''' Removes transparent pixels from an element and automatically resizes it.
  1347.         ''' </summary>
  1348.         ''' <param name="ImageElement">
  1349.         ''' Indicates the image draw element.
  1350.         ''' </param>
  1351.         Public Shared Sub RemoveTransparency(ByRef [ImageElement] As ImageElement)
  1352.  
  1353.             ' Create an instance of RemoveTransparency class
  1354.             Dim Action As New RemoveTransparency()
  1355.  
  1356.             ' Apply the action on the ImageElement.
  1357.             [ImageElement].Actions.Add(Action)
  1358.  
  1359.         End Sub
  1360.  
  1361.         ''' <summary>
  1362.         ''' Changes the size of an image.
  1363.         ''' </summary>
  1364.         ''' <param name="ImageElement">
  1365.         ''' Indicates the image draw element.
  1366.         ''' </param>
  1367.         ''' <param name="Width">
  1368.         ''' Indicates the new image Width.
  1369.         ''' </param>
  1370.         ''' <param name="Height">
  1371.         ''' Indicates the new image Height.
  1372.         ''' </param>
  1373.         ''' <param name="LockAspectRatio">
  1374.         ''' Indicates how element's proportions are maintained.
  1375.         ''' </param>
  1376.         ''' <param name="InterpolationMode">
  1377.         ''' Indicates the algorithm that is used when images are scaled or rotated.
  1378.         ''' </param>
  1379.         Public Shared Sub Resize(ByRef [ImageElement] As ImageElement,
  1380.                                  ByVal Width As Integer,
  1381.                                  ByVal Height As Integer,
  1382.                                  ByVal LockAspectRatio As LockAspectRatio,
  1383.                                  ByVal InterpolationMode As Drawing2D.InterpolationMode)
  1384.  
  1385.             ' Create an instance of Resize class
  1386.             Dim Action As New Resize()
  1387.  
  1388.             With Action
  1389.  
  1390.                 ' Set the new image Width.
  1391.                 .Width = Width
  1392.  
  1393.                 ' Set the new image Height.
  1394.                 .Height = Height
  1395.  
  1396.                 ' Set how element's proportions are maintained.
  1397.                 .LockAspectRatio = LockAspectRatio
  1398.  
  1399.                 ' Set the algorithm that is used when images are scaled or rotated.
  1400.                 .InterpolationMode = InterpolationMode
  1401.  
  1402.             End With
  1403.  
  1404.             ' Apply the action on the ImageElement.
  1405.             [ImageElement].Actions.Add(Action)
  1406.  
  1407.         End Sub
  1408.  
  1409.         ''' <summary>
  1410.         ''' Rotates an image.
  1411.         ''' </summary>
  1412.         ''' <param name="ImageElement">
  1413.         ''' Indicates the image draw element.
  1414.         ''' </param>
  1415.         ''' <param name="Angle">
  1416.         ''' Indicates the rotation angle.
  1417.         ''' Value range from 0 to 360.
  1418.         ''' </param>
  1419.         ''' <param name="InterpolationMode">
  1420.         ''' Indicates the algorithm that is used when images are scaled or rotated.
  1421.         ''' </param>
  1422.         Public Shared Sub Rotate(ByRef [ImageElement] As ImageElement,
  1423.                                  ByVal Angle As Integer,
  1424.                                  ByVal InterpolationMode As Drawing2D.InterpolationMode)
  1425.  
  1426.             ' Create an instance of Rotate class
  1427.             Dim Action As New Rotate()
  1428.  
  1429.             With Action
  1430.  
  1431.                 ' Set the rotation angle.
  1432.                 .Angle = Angle
  1433.  
  1434.                 ' Set the algorithm that is used when images are scaled or rotated.
  1435.                 .InterpolationMode = InterpolationMode
  1436.  
  1437.             End With
  1438.  
  1439.             ' Apply the action on the ImageElement.
  1440.             [ImageElement].Actions.Add(Action)
  1441.  
  1442.         End Sub
  1443.  
  1444.         ''' <summary>
  1445.         ''' Rounds image corners.
  1446.         ''' </summary>
  1447.         ''' <param name="ImageElement">
  1448.         ''' Indicates the image draw element.
  1449.         ''' </param>
  1450.         ''' <param name="Corners">
  1451.         ''' Indicates what corners will be rounded.
  1452.         ''' </param>
  1453.         ''' <param name="Roundness">
  1454.         ''' Indicates the corner roundness.
  1455.         ''' </param>
  1456.         Public Shared Sub RoundCorners(ByRef [ImageElement] As ImageElement,
  1457.                                        ByVal Corners As Corners,
  1458.                                        ByVal Roundness As Integer)
  1459.  
  1460.             ' Create an instance of RoundCorners class
  1461.             Dim Action As New RoundCorners()
  1462.  
  1463.             With Action
  1464.  
  1465.                 ' Set what corners will be rounded.
  1466.                 .Corners = Corners
  1467.  
  1468.                 ' Set the corner roundness.
  1469.                 .Roundness = Roundness
  1470.  
  1471.             End With
  1472.  
  1473.             ' Apply the action on the ImageElement.
  1474.             [ImageElement].Actions.Add(Action)
  1475.  
  1476.         End Sub
  1477.  
  1478.         ''' <summary>
  1479.         ''' Rounds image corners.
  1480.         ''' </summary>
  1481.         ''' <param name="ImageElement">
  1482.         ''' Indicates the image draw element.
  1483.         ''' </param>
  1484.         ''' <param name="Corners">
  1485.         ''' Indicates what corners will be rounded.
  1486.         ''' </param>
  1487.         ''' <param name="Roundness">
  1488.         ''' Indicates the corner roundness.
  1489.         ''' </param>
  1490.         ''' <param name="BorderWidth">
  1491.         ''' Indicates the border width.
  1492.         ''' </param>
  1493.         ''' <param name="BorderColor">
  1494.         ''' Indicates the border color.
  1495.         ''' </param>
  1496.         Public Shared Sub RoundCorners(ByRef [ImageElement] As ImageElement,
  1497.                                        ByVal Corners As Corners,
  1498.                                        ByVal Roundness As Integer,
  1499.                                        ByVal BorderWidth As Integer,
  1500.                                        ByVal BorderColor As Color)
  1501.  
  1502.             ' Create an instance of RoundCorners class
  1503.             Dim Action As New RoundCorners()
  1504.  
  1505.             With Action
  1506.  
  1507.                 ' Set what corners will be rounded.
  1508.                 .Corners = Corners
  1509.  
  1510.                 ' Set the corner roundness.
  1511.                 .Roundness = Roundness
  1512.  
  1513.                 ' Set the border width.
  1514.                 .BorderWidth = BorderWidth
  1515.  
  1516.                 ' Set the border color.
  1517.                 .BorderColor = BorderColor
  1518.  
  1519.             End With
  1520.  
  1521.             ' Apply the action on the ImageElement.
  1522.             [ImageElement].Actions.Add(Action)
  1523.  
  1524.         End Sub
  1525.  
  1526.         ''' <summary>
  1527.         ''' Enlarges or reduces the size of an image.
  1528.         ''' </summary>
  1529.         ''' <param name="ImageElement">
  1530.         ''' Indicates the image draw element.
  1531.         ''' </param>
  1532.         ''' <param name="WidthPercentage">
  1533.         ''' Indicates the new element Width based on a percentage of the original Width.
  1534.         ''' </param>
  1535.         ''' <param name="HeightPercentage">
  1536.         ''' Indicates the new element Height based on a percentage of the original Height.
  1537.         ''' </param>
  1538.         ''' <param name="InterpolationMode">
  1539.         ''' Indicates the algorithm that is used when images are scaled or rotated.
  1540.         ''' </param>
  1541.         Public Shared Sub Scale(ByRef [ImageElement] As ImageElement,
  1542.                                 ByVal WidthPercentage As Integer,
  1543.                                 ByVal HeightPercentage As Integer,
  1544.                                 ByVal InterpolationMode As Drawing2D.InterpolationMode)
  1545.  
  1546.             ' Create an instance of Scale class
  1547.             Dim Action As New Scale()
  1548.  
  1549.             With Action
  1550.  
  1551.                 ' Set the new element Width based on a percentage of the original Width.
  1552.                 .WidthPercentage = WidthPercentage
  1553.  
  1554.                 ' Set the new element Height based on a percentage of the original Height.
  1555.                 .HeightPercentage = HeightPercentage
  1556.  
  1557.                 ' Set the algorithm that is used when images are scaled or rotated.
  1558.                 .InterpolationMode = InterpolationMode
  1559.  
  1560.             End With
  1561.  
  1562.             ' Apply the action on the ImageElement.
  1563.             [ImageElement].Actions.Add(Action)
  1564.  
  1565.         End Sub
  1566.  
  1567.         ''' <summary>
  1568.         ''' Sharpens an element trying to enhance the overall visual impression.
  1569.         ''' </summary>
  1570.         ''' <param name="ImageElement">
  1571.         ''' Indicates the image draw element.
  1572.         ''' </param>
  1573.         Public Shared Sub Sharpen(ByRef [ImageElement] As ImageElement)
  1574.  
  1575.             ' Create an instance of Sharpen class
  1576.             Dim Action As New Sharpen()
  1577.  
  1578.             ' Apply the action on the ImageElement.
  1579.             [ImageElement].Actions.Add(Action)
  1580.  
  1581.         End Sub
  1582.  
  1583.         ''' <summary>
  1584.         ''' Creates a Silhouette of an element.
  1585.         ''' </summary>
  1586.         ''' <param name="ImageElement">
  1587.         ''' Indicates the image draw element.
  1588.         ''' </param>
  1589.         ''' <param name="SilhouetteColor">
  1590.         ''' Indicates the Silhouette color.
  1591.         ''' </param>
  1592.         Public Shared Sub Silhouette(ByRef [ImageElement] As ImageElement,
  1593.                                      ByVal SilhouetteColor As Color)
  1594.  
  1595.             ' Create an instance of Silhouette class
  1596.             Dim Action As New Silhouette()
  1597.  
  1598.             With Action
  1599.  
  1600.                 ' Set the Silhouette color.
  1601.                 .Color = SilhouetteColor
  1602.  
  1603.             End With
  1604.  
  1605.             ' Apply the action on the ImageElement.
  1606.             [ImageElement].Actions.Add(Action)
  1607.  
  1608.         End Sub
  1609.  
  1610.         ''' <summary>
  1611.         ''' Skews an element.
  1612.         ''' Skewing an element transforms it by slanting it along the horizontal or vertical axis.
  1613.         ''' When skewed, an element pivots on its origin point.
  1614.         ''' </summary>
  1615.         ''' <param name="ImageElement">
  1616.         ''' Indicates the image draw element.
  1617.         ''' </param>
  1618.         ''' <param name="Type">
  1619.         ''' Indicates the skewing type.
  1620.         ''' </param>
  1621.         ''' <param name="Angle">
  1622.         ''' Indicates the skewing angle.
  1623.         ''' Value ange from -45 to 45.
  1624.         ''' </param>
  1625.         ''' <param name="Orientation">
  1626.         ''' Indicates the skewing orientation.
  1627.         ''' </param>
  1628.         ''' <param name="ConstrainProportions">
  1629.         ''' Indicates whether maintaing the same proportions as the original.
  1630.         ''' </param>
  1631.         Public Shared Sub Skew(ByRef [ImageElement] As ImageElement,
  1632.                                ByVal Type As SkewType,
  1633.                                ByVal Angle As Integer,
  1634.                                ByVal Orientation As SkewOrientation,
  1635.                                ByVal ConstrainProportions As Boolean)
  1636.  
  1637.             ' Create an instance of Skew class
  1638.             Dim Action As New Skew()
  1639.  
  1640.             With Action
  1641.  
  1642.                 ' Set the skewing angle.
  1643.                 .Angle = Angle
  1644.  
  1645.                 ' Set the skewing type.
  1646.                 .Type = Type
  1647.  
  1648.                 ' Set the skewing orientation.
  1649.                 .Orientation = Orientation
  1650.  
  1651.                 ' Set whether maintaing the same proportions as the original.
  1652.                 .ConstrainProportions = ConstrainProportions
  1653.  
  1654.             End With
  1655.  
  1656.             ' Apply the action on the ImageElement.
  1657.             [ImageElement].Actions.Add(Action)
  1658.  
  1659.         End Sub
  1660.  
  1661.         ''' <summary>
  1662.         ''' Solarizes an element.
  1663.         ''' </summary>
  1664.         ''' <param name="ImageElement">
  1665.         ''' Indicates the image draw element.
  1666.         ''' </param>
  1667.         Public Shared Sub Solarize(ByRef [ImageElement] As ImageElement)
  1668.  
  1669.             ' Create an instance of Solarize class
  1670.             Dim Action As New Solarize()
  1671.  
  1672.             ' Apply the action on the ImageElement.
  1673.             [ImageElement].Actions.Add(Action)
  1674.  
  1675.         End Sub
  1676.  
  1677.         ''' <summary>
  1678.         ''' Stretches an image to fit a given size.
  1679.         ''' </summary>
  1680.         ''' <param name="ImageElement">
  1681.         ''' Indicates the image draw element.
  1682.         ''' </param>
  1683.         ''' <param name="Width">
  1684.         ''' Indicates the new element Width.
  1685.         ''' </param>
  1686.         ''' <param name="Height">
  1687.         ''' Indicates the new element Height.
  1688.         ''' </param>
  1689.         Public Shared Sub Stretch(ByRef [ImageElement] As ImageElement,
  1690.                                   ByVal Width As Integer,
  1691.                                   ByVal Height As Integer)
  1692.  
  1693.             ' Create an instance of Stretch class
  1694.             Dim Action As New Stretch()
  1695.  
  1696.             With Action
  1697.  
  1698.                 ' Set the new image Width.
  1699.                 .Width = Width
  1700.  
  1701.                 ' Set the new image Height.
  1702.                 .Height = Height
  1703.  
  1704.             End With
  1705.  
  1706.             ' Apply the action on the ImageElement.
  1707.             [ImageElement].Actions.Add(Action)
  1708.  
  1709.         End Sub
  1710.  
  1711.         ''' <summary>
  1712.         ''' Creates a tinted look of an element.
  1713.         ''' </summary>
  1714.         ''' <param name="ImageElement">
  1715.         ''' Indicates the image draw element.
  1716.         ''' </param>
  1717.         ''' <param name="TintColor">
  1718.         ''' Indicates the color used for tinting.
  1719.         ''' </param>
  1720.         Public Shared Sub Tint(ByRef [ImageElement] As ImageElement,
  1721.                                ByVal TintColor As Color)
  1722.  
  1723.             ' Create an instance of Tint class
  1724.             Dim Action As New Tint()
  1725.  
  1726.             With Action
  1727.  
  1728.                 ' Set the color used for tinting.
  1729.                 .Color = TintColor
  1730.  
  1731.             End With
  1732.  
  1733.             ' Apply the action on the ImageElement.
  1734.             [ImageElement].Actions.Add(Action)
  1735.  
  1736.         End Sub
  1737.  
  1738.     End Class
  1739.  
  1740. #End Region
  1741.  
  1742. End Class
  1743.  
  1744. #End Region
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement