Petter L.
Dim imgX As Integer
Dim imgY As Integer
imgX = PictureBox1.Image.Height
imgY = PictureBox1.Image.Width
PictureBox1.Image.RotateFlip(RotateFlipType.Rotate90FlipNone)
PictureBox1.Height = imgY
PictureBox1.Width = imgX
james
"petterl" <petter...@hotmail.com> wrote in message
news:%231tugho...@TK2MSFTNGP11.phx.gbl...
Here is the code for rotating in my menu item
Me.PictureBox1.SizeMode = PictureBoxSizeMode.Normal
Me.PictureBox1.Image.RotateFlip(RotateFlipType.Rotate270FlipNone)
Me.PictureBox1.Refresh()
SetPictureBoxSize()
Fit()
Code for those two routines:
Private Sub Fit()
If Me.PictureBox1.Image.Width < Me.PictureBox1.Width And _
Me.PictureBox1.Image.Height < Me.PictureBox1.Height Then
Me.PictureBox1.SizeMode = PictureBoxSizeMode.AutoSize 'CenterImage
End If
CalculateAspectRatioAndSetDimensions()
End Sub
Private Function CalculateAspectRatioAndSetDimensions() As Double
' Calculate the proper aspect ratio and set the image's dimensions.
Dim ratio As Double
If Me.PictureBox1.Image.Width > Me.PictureBox1.Image.Height Then
ratio = Me.PictureBox1.Image.Width / _
Me.PictureBox1.Image.Height
Me.PictureBox1.Height = CInt(CDbl(Me.PictureBox1.Width) / ratio)
Else
ratio = Me.PictureBox1.Image.Height / _
Me.PictureBox1.Image.Width
Me.PictureBox1.Width = CInt(CDbl(Me.PictureBox1.Height) / ratio)
End If
Return ratio
End Function
Private Sub SetPictureBoxSize()
If PictureBox1.Width > SystemInformation.WorkingArea.Width Then
Me.Width = SystemInformation.WorkingArea.Width
End If
If PictureBox1.Height > SystemInformation.WorkingArea.Height Then
Me.Height = SystemInformation.WorkingArea.Height
End If
End Sub
I just get a picture with a empty space between the actual picture and the
picturebox even with your code in it.
"james" <jjam...@earthlink.net> wrote in message
news:esEWdgqE...@TK2MSFTNGP11.phx.gbl...
That should fix it.
james
"Petter L." <petter...@hotmail.com> wrote in message
news:ugMH8nvE...@TK2MSFTNGP11.phx.gbl...