Guest User

Untitled

a guest
Feb 14th, 2014
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.76 KB | None | 0 0
  1.  Public Function GenerateThumbnail(ByVal original As Image, ByVal percentage As Integer) As Image
  2.         Dim image As New Bitmap(Picturebox1.Image)
  3.         If percentage < 1 Then
  4.             Throw New Exception("Thumbnail size must be aat least 1% of the original size")
  5.         End If
  6.         Dim tn As New Bitmap(CInt(original.Width * 0.01F * percentage), CInt(original.Height * 0.01F * percentage))
  7.         Dim g As Graphics = Graphics.FromImage(tn)
  8.         g.InterpolationMode = InterpolationMode.HighQualityBilinear
  9.         'experiment with this...
  10.         g.DrawImage(original, New Rectangle(0, 0, tn.Width, tn.Height), 0, 0, original.Width, original.Height, _
  11.          GraphicsUnit.Pixel)
  12.         g.Dispose()
  13.         Return DirectCast(tn, Image)
  14.     End Function
Advertisement
Add Comment
Please, Sign In to add comment