PageRenderTime 9ms CodeModel.GetById 2ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/Source Code/PowerSong/GraphicRoutines.vb

#
Visual Basic | 25 lines | 13 code | 5 blank | 7 comment | 0 complexity | 0c840227158314c4edac02ae6161bb27 MD5 | raw file
 1Imports System.Drawing.Drawing2D
 2
 3Module GraphicRoutines
 4
 5    ''' <summary>
 6    ''' Resizes the given image to the given width and height, using interpolation.
 7    ''' </summary>
 8    ''' <param name="sourceImage">The image to resize.</param>
 9    ''' <param name="width">The width of the resulting image.</param>
10    ''' <param name="height">The height of the resulting image.</param>
11    ''' <returns>The resized image.</returns>
12    Function Resize(ByVal sourceImage As Image, ByVal width As Integer, ByVal height As Integer) As Bitmap
13
14        Dim Result As New Bitmap(width, height, Imaging.PixelFormat.Format24bppRgb)
15        Dim G As Graphics = Graphics.FromImage(Result)
16        G.InterpolationMode = InterpolationMode.HighQualityBicubic
17        G.DrawImage(sourceImage, _
18                    New Rectangle(0, 0, width, height), _
19                    New Rectangle(0, 0, sourceImage.Width, sourceImage.Height), GraphicsUnit.Pixel)
20        G.Dispose()
21        Return Result
22
23    End Function
24
25End Module