|
Imports System.Drawing
Imports System.Drawing.Drawing2D
Public Class ResizeFilter
Inherits BasicFilter
''' <summary>
''' Width of new image.
''' </summary>
Private _width As Integer = 0
''' <summary>
''' Height of new image.
''' </summary>
Private _height As Integer = 0
''' <summary>
''' Get or set output image width.
''' </summary>
Public Property Width() As Integer
Get
Return _width
End Get
Set(ByVal value As Integer)
_width = value
End Set
End Property
''' <summary>
''' Get or set output image height.
''' </summary>
Public Property Height() As Integer
Get
Return _height
End Get
Set(ByVal value As Integer)
_height = value
End Set
End Property
''' <summary>
''' Execute resize of given image.
''' </summary>
''' <param name="img">Image to be resized.</param>
''' <returns>Resized image.</returns>
Public Overrides Function ExecuteFilter(ByVal img As System.Drawing.Image) As System.Drawing.Image
If ((img.Width <= 0) Or (img.Height <= 0) Or _
(_width <= 0) Or (_height <= 0)) Then
Return img
End If
Dim result As Bitmap = New Bitmap(_width, _height)
Dim g As Graphics = Graphics.FromImage(result)
g.InterpolationMode = Interpolation
g.DrawImage(img, 0, 0, _width, _height)
Return result
End Function
End Class
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.