VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

LoadImage() to Fit

Nuno Miguel Felicio  (1 Submission)   Custom Controls/Forms/Menus   Visual Basic 3.0   Unknown Difficulty   Wed 3rd February 2021

It's a single function, without API's, that loads an image and puts it in a destination PictureBox. If the source image is bigger that the destination PictureBox, then it will resized to fit in (mantaining the ratio). In other words, the image loaded will nicely fit the destination, but will not be deformed.
If the source is smaller, then it will remain that size...
This function is an upgrade (in speed, error trapping and results) of Jason Monroe original post. Thanks Janson.

Inputs
FilePath$ -> the path of the file to be loaded PicMain -> The destination picturebox of the image ImgMain -> An image object created inside PicMain (this image will be the "container" of the final image PicTemp -> A picture box used as temp during the process

Assumes
You need to know how to call a function... :-) Put the code as it is in a new module... and then call it... Use the return code to know if the image was loaded... PS We Only See Well With Our Heart; The Essential Things Are Invisible To Our Eyes! Greetings from Portugal...

Returns
0 -> The image was loaded ## -> The file was not loaded - Returns the vbError code

Side Effects
NOP

API Declarations
NOP

Rate LoadImage() to Fit (5(5 Vote))
LoadImage() to Fit.bas

LoadImage() to Fit Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters