Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Function GenerateThumbnail(ByVal original As Image, ByVal percentage As Integer) As Image
- Dim image As New Bitmap(Picturebox1.Image)
- If percentage < 1 Then
- Throw New Exception("Thumbnail size must be aat least 1% of the original size")
- End If
- Dim tn As New Bitmap(CInt(original.Width * 0.01F * percentage), CInt(original.Height * 0.01F * percentage))
- Dim g As Graphics = Graphics.FromImage(tn)
- g.InterpolationMode = InterpolationMode.HighQualityBilinear
- 'experiment with this...
- g.DrawImage(original, New Rectangle(0, 0, tn.Width, tn.Height), 0, 0, original.Width, original.Height, _
- GraphicsUnit.Pixel)
- g.Dispose()
- Return DirectCast(tn, Image)
- End Function
Advertisement
Add Comment
Please, Sign In to add comment