blah blah blah is here! blah blah » Close

up1down
link

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.

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 answered one year ago

1 answers

link

Try the following:

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();
}
}

wert123
18

thx, it work perfect :D

Feedback