|
-
Oct 18th, 2006, 03:34 AM
#1
Thread Starter
Fanatic Member
Rotate Graphics path
Hi,
I dont know what I am doing wrong here but for some reason the graphics path does not rotate properly, I have created a user control that loads in a graphics path and will scale the path to the size of the user control which is fine, but when I go to rotate the path the rotation goes all wrong, could someone please look at my code? if you want my sample project I will send it.
VB Code:
protected override void OnResize(EventArgs eventargs)
{
base.OnResize(eventargs);
DrawPath();
}
private void DrawPath()
{
Bitmap b = new Bitmap(this.Width, this.Height);
Graphics e = Graphics.FromImage(b);
if (Mainpath != null)
{
try
{
float x = 0f;
float y = 0f;
x = (this.Width) / ((float)Mainpath.GetBounds().Width + 1);
y = (this.Height) / ((float)Mainpath.GetBounds().Height + 1);
Matrix m = new Matrix();
m.Scale(x, y);
Mainpath.Transform(m);
e.DrawPath(new Pen(Color.Black), Mainpath);
this.BackgroundImage = b;
}
catch { }
}
}
private void Rotate(float Value)
{
try
{
Matrix m = new Matrix();
m.RotateAt(Value, new PointF(this.Width /2,this.Height / 2));
Mainpath.Transform(m);
DrawPath();
}
catch { };
}
private float m_RotateAnglePath;
public float RotateAnglePath
{
get { return m_RotateAnglePath; }
set
{
m_RotateAnglePath = value;
Rotate((int)RotateAnglePath);
}
}
Thanks
Loftty
-
Oct 18th, 2006, 07:21 PM
#2
Re: Rotate Graphics path
Check out this thread
http://www.vbforums.com/showthread.php?t=391330 (rotate and zoom image)
Its vb.NET but you'll get the idea.
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
|