
Oct 22nd, 2019, 12:37 PM
#1
Thread Starter
Hyperactive Member
Comparing the size of Picture1 with the sizes of Picture2, Picture3, and Picture4
I have 4 Pictureboxes, Picture1, 2, 3,and 4. I need to know which Picturebox of 2, 3, and 4 is the closest in overall size to Picture1
For example:
Picture1 is 663w x 516h
Picture2 is 658w x 526h
Picture3 is 682w x 511h
Picture4 is 688w x 481h
I know by looking at the size of each Picturebox, Picture2 is the closest to Picture1
I used the area size of each Picture and picked the smallest results and I got Picture2 as the answer but I am not sure this will work in all cases
How would you go about determining this code wise

Oct 22nd, 2019, 12:55 PM
#2
Re: Comparing the size of Picture1 with the sizes of Picture2, Picture3, and Picture4
Assuming you are simply multiplying w*h, that would mean that an image that is 171054w x 2h would be "equal" to Picture1 since their areas are equal; but that would clearly be a wrong answer visually.
My initial thought would be to do it this way:
Calculate dw as abs(pic1.width  picN.width)
Calculate dh as abs(pic1.height  picN.height)
Then calculate:
dA = dw*pic1.height + dh*pic1.width + dw*dh
and whatever picturebox minimizes dA would be "closest"

Oct 22nd, 2019, 03:42 PM
#3
Thread Starter
Hyperactive Member
Re: Comparing the size of Picture1 with the sizes of Picture2, Picture3, and Picture4
Is this what you mean
Dim dw As Long, dh As Long, dA As Long
dw = Abs(Picture1.Width  Picture2.Width)
dh = Abs(Picture1.Height  Picture2.Height)
dA = dw * Picture1.Height + dh * Picture1.Width + dw * dh 'dA = 9260
dw = Abs(Picture1.Width  Picture3.Width)
dh = Abs(Picture1.Height  Picture3.Height)
dA = dw * Picture1.Height + dh * Picture1.Width + dw * dh 'dA = 13214
dw = Abs(Picture1.Width  Picture4.Width)
dh = Abs(Picture1.Height  Picture4.Height)
dA = dw * Picture1.Height + dh * Picture1.Width + dw * dh 'dA = 36980
I would pick the 1st example of 9260

Oct 22nd, 2019, 04:39 PM
#4
Re: Comparing the size of Picture1 with the sizes of Picture2, Picture3, and Picture4

Oct 22nd, 2019, 04:42 PM
#5
Thread Starter
Hyperactive Member
Re: Comparing the size of Picture1 with the sizes of Picture2, Picture3, and Picture4
Thank you, very appreciated
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
