PageRenderTime 49ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/Source Code/PowerSong/GraphicRoutines.vb

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