VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Resizing a picture algorithm

by Peter Rosconi (4 Submissions)
Category: Graphics
Compatability: Visual Basic 3.0
Difficulty: Advanced
Date Added: Wed 3rd February 2021
Rating: (2 Votes)

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

Inputs
startingPic As PictureBox, destinationPic As PictureBox
Assumes
Must have two picture boxes the 'starting picture box' must have a picture already loaded into it.
Side Effects
Not the most efficient way to resize a picture.

Rate Resizing a picture algorithm

'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

Download this snippet    Add to My Saved Code

Resizing a picture algorithm Comments

No comments have been posted about Resizing a picture algorithm. Why not be the first to post a comment about Resizing a picture algorithm.

Post your comment

Subject:
Message:
0/1000 characters