Advertisement
ASP_Volume2 Graphics #30786

Resizing a picture algorithm

It resizes any size picture in a picturebox into another any size picturebox. I made this to show an algorithm of resizing a picture.

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
'pretty much straight forward just load a picture
'  into 'startingPic' and call this sub
Public Sub ResizePicture(startingPic As PictureBox, destinationPic As PictureBox)
'the horz. and vert. ratios
ratioX = startingPic.ScaleWidth / destinationPic.ScaleWidth
ratioY = startingPic.ScaleHeight / destinationPic.ScaleHeight
'for stats
theTimer = Timer
'go through the startingPic's pixels
For x = 0 To startingPic.ScaleWidth Step ratioX
For y = 0 To startingPic.ScaleHeight Step ratioY
  'get the color of the startingPic
  theColor = startingPic.Point(x, y)
  
  'find the corresponding x and y values
  ' for the resized destination pic
  realX = ratioX ^ -1 * x
  realY = ratioY ^ -1 * y
  
  destinationPic.PSet (realX, realY), theColor
Next y
Next x
MsgBox "It took " & Timer - theTimer & " seconds to increase the horizontal size by " & ratioX ^ -1 & " and the vertical size by " & ratioY ^ -1 & "."
End Sub
Original Comments (3)
Recovered from Wayback Machine