March 18th, 2010, 05:38 PM
#1
[RESOLVED] c# rotate image
hello
the title says everything, i want to rotate an image but it dont rotate around his center it rotates in a circle around the form.
Code:
for(int i=0;i<500;i++)
{
Image m=Image.FromFile("C:/p1.png");
using(Graphics g=this.CreateGraphics())
{
g.TranslateTransform(m.Width/2,m.Height/2);
g.RotateTransform(i);
g.TranslateTransform(-m.Width/2,-m.Height/2);
g.DrawImage(m,new Point(100,100));
}
}
if I put in DrawImage(m,0,0) i works great but i dont want to rotate the image in the corner.
sorry for the english but I think you understud what I ask
Last edited by HanneSThEGreaT; March 19th, 2010 at 02:56 AM .
March 18th, 2010, 06:43 PM
#2
Re: c# rotate image
You don't need to Transform, you need to Rotate only
March 19th, 2010, 03:24 AM
#3
Re: c# rotate image
wert1234, please make use of [CODE] tags when posting code
March 19th, 2010, 03:30 AM
#4
Re: c# rotate image
Originally Posted by
dglienna
You don't need to Transform, you need to Rotate only
if I remove the Transform it work samo, the image rorates over the form
Originally Posted by
HanneSThEGreaT
wert1234, please make use of [CODE] tags when posting code
sorry for that
Attached Images
March 19th, 2010, 06:26 AM
#5
Re: c# rotate image
problem solved
Code:
Image m = Image.FromFile(@"C:\p1.png");
using (Graphics gfx = this.CreateGraphics())
{
for (int i = 0; i <= 360; i++)
{
Bitmap b = new Bitmap(m.Width, m.Height);
using (Graphics g = Graphics.FromImage(b))
{
g.TranslateTransform(m.Width / 2, m.Height / 2);
g.RotateTransform(i);
g.TranslateTransform(-m.Width / 2, -m.Height / 2);
g.DrawImage(m, 0, 0);
}
gfx.DrawImage(b, 100, 100);
b.Dispose();
}
}
the thread can be locked, deleted or what you want
March 19th, 2010, 07:17 AM
#6
April 17th, 2013, 01:24 AM
#7
Re: [RESOLVED] c# rotate image
this is a method i found on the internet, you can give a try. a way of rotating an image
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