|
-
Jan 7th, 2003, 12:25 PM
#1
Thread Starter
Registered User
rotating an image, by not using the defaulted upper left corner for rotation point
If anyone can help me out here, i would really appreciate it. I am trying to do a relatively simple task -> Rotate a Picture. Which works fine. But the problem is, my code uses the upper left corner to rotate the image. Is it possible to change that to the middle, or the origin, so that i can rotate the picture from the center. If so, how is this done? Here is the sample code, basically it is a panel on a form, and this is it's paint event. It loads a picture from the programs bin folder. Thanks alot...
Jeff
VB Code:
Private Sub TextArea_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles TextArea.Paint
Dim sa As System.Drawing.Size
sa = TextArea.Size
Dim middle As New Point(sa.Width / 4, sa.Height / 3)
e.Graphics.TranslateTransform(middle.X, middle.Y)
'Apply all transforms....
e.Graphics.RotateTransform(45) 'angle to rotate
Dim bmp As New Bitmap("sample.jpg")
e.Graphics.DrawImage(bmp, 0, 0)
End Sub
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
|