I have created a functin that scales an image.
The scaling appears to go ok, but the problem is that I have no idea how to get the scaled graphic (gt_dest) back into the picturebox (picBannerBox) that is on Form1.
How do I do that?
Private Function ScaleImage(ByVal imgTemp As Image, ByVal box As PictureBox) As Graphics
Dim fSize As String
Dim iNewx As Integer = 0
Dim iNewy As Integer = 0
Dim oldBMP As New Bitmap(CInt(imgTemp.Width), CInt(imgTemp.Height))
'Determine which side is larger than the canvas,
If ImageTooWide(imgTemp) And ImageTooTall(imgTemp) Then
'...and if both are larger, pick the larger side.
If imgTemp.Height > imgTemp.Width Then
fSize = "height"
fSize = "width"
'... Other wise pick the one that is larger.
If ImageTooWide(imgTemp) Then fSize = "width"
If ImageTooTall(imgTemp) Then fSize = "height"
Select Case fSize
iNewx = picBannerBox.Width
iNewy = iNewx / imgTemp.Width * imgTemp.Height
iNewy = picBannerBox.Height
iNewx = iNewy / imgTemp.Height * imgTemp.Width
Dim newBMP As New Bitmap(iNewx, iNewy)
'Create a blank, new graphic that is the correct *new* size
Dim gt_dest As Graphics = Graphics.FromImage(newBMP)
'Draw our picture onto it, scaling it...
gt_dest.DrawImage(imgTemp, 0, 0, iNewx + 1, iNewy + 1)
'Draw new image to picBannerBox