Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to Resize a form after rotate a picture

10 views
Skip to first unread message

petterl

unread,
May 4, 2003, 5:52:35 PM5/4/03
to
How can I set the picturebox and form window so it fit the rotated picture
at 90 degree turned.
My currently result is that the picture after turning got chopped off and
have a opend space between form and the actual picture inside the
picturebox.

Petter L.


petterl

unread,
May 4, 2003, 5:58:46 PM5/4/03
to

james

unread,
May 4, 2003, 9:46:10 PM5/4/03
to
In VB.Net something like this:

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...

Petter L.

unread,
May 5, 2003, 7:32:15 AM5/5/03
to
Thanks but it didn't help at all.

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...

james

unread,
May 5, 2003, 11:29:42 PM5/5/03
to
Duh,,,,,,,,,,,sorry. Comment out your code in your sub Set Picturebox size,
and add the code I gave you then at the end add this:
Picturebox1.Refresh()

That should fix it.
james

"Petter L." <petter...@hotmail.com> wrote in message
news:ugMH8nvE...@TK2MSFTNGP11.phx.gbl...

0 new messages