|
-
Jun 2nd, 2000, 10:16 AM
#1
I have various picture sizes 800x600, 640x480... is there a way to shrink and expand them automatically to fit the image box I create on a form?
-
Jun 2nd, 2000, 10:54 AM
#2
Fanatic Member
Size your image box and set STRETCH property to true
DocZaf
{;->
-
Jun 2nd, 2000, 11:26 AM
#3
If i set it to stretch some o fthe thinner pics lok very distorted? Can I stretch it to fit the box, center the picture in the box, and keep it porportional to the box that it is in?
-
Jun 2nd, 2000, 07:03 PM
#4
Lively Member
Hi. You can look at this code. Make a form and a imagebox in it. You can now resize the form but the propotions are right.
Private Sub Form_Resize()
Image1.Width = Me.ScaleWidth
Image1.Height = Me.ScaleHeight
ScaleImage
End Sub
Public Sub ScaleImage()
Dim intDelen, intDelen2
If Image1.Picture.Width = 0 And Image1.Picture.Height = 0 Then Exit Sub
intDelen = 0
intDelen2 = 0
If Me.ScaleWidth < (Image1.Picture.Width / 2) Or Me.ScaleHeight < (Image1.Picture.Height / 2) Then
intDelen = ((Image1.Picture.Width / 2) - Me.ScaleWidth) / (Image1.Picture.Width / 2)
intDelen2 = ((Image1.Picture.Height / 2) - Me.ScaleHeight) / (Image1.Picture.Height / 2)
If intDelen >= intDelen2 Then
Image1.Width = (Image1.Picture.Width / 2) * (1 - intDelen)
Image1.Height = (Image1.Picture.Height / 2) * (1 - intDelen)
Else
Image1.Height = (Image1.Picture.Height / 2) * (1 - intDelen2)
Image1.Width = (Image1.Picture.Width / 2) * (1 - intDelen2)
End If
Else
Image1.Width = (Image1.Picture.Width / 2)
Image1.Height = (Image1.Picture.Height / 2)
End If
Image1.Top = (frmImage.ScaleHeight / 2) - (Image1.Height / 2)
Image1.Left = (frmImage.ScaleWidth / 2) - (Image1.Width / 2)
End Sub
-
Jun 3rd, 2000, 04:06 AM
#5
thanks for the code, is there any way that it can be modified so that it automatically sizes the picture to fit in the screen, and the user does not have the ability to resize the screen.
-
Jun 3rd, 2000, 07:15 AM
#6
Fanatic Member
This is one way
It might not be the shortest number of code lines
but it isn't difficult to see whats going on
myform.top=0
myform.left=0
myform.width=screen.width
myform.height=screen.height
'taking it for granted that
'the border is double or sizable
myimage.width=(myform.width-120)
myimage.height=myform.height-420
myimage.stretch=true
load picture
DocZaf
{;->
-
Jun 3rd, 2000, 02:59 PM
#7
Lively Member
Use my code and add this
Private Sub Form_Load()
Me.Width = Screen.Width
Me.Hight = Scree.Hight
Form_Resize
End Sub
Now will the picturebox be adjust to the screen, and to the user so It shall not me resizeable just set the Form properties BorderStyle to 1 or 3 (depends if you want to use the Maximum and Minimum bottons).
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
|