-
Jan 27th, 2007, 12:12 PM
#1
Thread Starter
Lively Member
A simple function for resizing an image
VB Code:
Public Function ResizeImage(ByVal iImage As Bitmap, ByVal ScaleX As Single, ByVal ScaleY As Single, ByVal iMode As InterpolationMode) As Bitmap
'Receives an image as input and scales it up or down
Dim g As Graphics
Dim sImage As Bitmap = New Bitmap(CInt(iImage.Width * ScaleX), CInt(iImage.Height * ScaleY))
g = Graphics.FromImage(sImage)
g.InterpolationMode = iMode
g.DrawImage(iImage, 0, 0, sImage.Width, sImage.Height)
ResizeImage = sImage
End Function
SYNTAX:
Where MyResizedImage is a bitmap
MyResizedImage = ResizeImage(iImage, ScaleX, ScaleY, iMode)
PARAMETERS:
iImage is the bitmap image to be resized
ScaleX is the percentage to multiply the original width
ScaleY is the percentage to multiply the original height
iMode is the desired interpolation mode
Last edited by AlphaScorpious; Jan 28th, 2007 at 03:04 AM.
-
Jan 28th, 2007, 02:17 AM
#2
Re: A simple function for resizing an image
wouldnt it work better if you change:
VB Code:
Public Function ResizeImage(ByVal iImage As Bitmap, ByVal ScaleX As Single, ByVal ScaleY As Single, ByVal iMode As Integer) As Bitmap
to:
VB Code:
Public Function ResizeImage(ByVal iImage As Bitmap, ByVal ScaleX As Single, ByVal ScaleY As Single, ByVal iMode As InterpolationMode) As Bitmap
g.InterpolationMode = iMode
?
-
Jan 28th, 2007, 03:07 AM
#3
Thread Starter
Lively Member
Re: A simple function for resizing an image
Originally Posted by JuggaloBrotha
wouldnt it work better if you change:
VB Code:
Public Function ResizeImage(ByVal iImage As Bitmap, ByVal ScaleX As Single, ByVal ScaleY As Single, ByVal iMode As Integer) As Bitmap
to:
VB Code:
Public Function ResizeImage(ByVal iImage As Bitmap, ByVal ScaleX As Single, ByVal ScaleY As Single, ByVal iMode As InterpolationMode) As Bitmap
g.InterpolationMode = iMode
?
That's the difference between a programmer and someone who can program.
The original code has been edited to implement JuggaloBrotha's suggestion.
-
Jun 24th, 2013, 11:09 PM
#4
Banned
Re: A simple function for resizing an image
hhh, i am just looking for a method to resize images, now i get it. tks, guys
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|