그러냐

이미지 회전 본문

c#

이미지 회전

관절분리 2016. 1. 28. 11:24
반응형

private void DrawAnalogClock(Graphics g)
        {
            int center = baseX + picH / 2;
            //int centerY = baseY + picW / 2;

            double valueAngle = 2 * Math.PI * (value+45/*Center Angle*/) / 100;

            //double radian = valueAngle * (Math.PI / 180);

            //g.DrawLine(new Pen(Brushes.Red, 7), center, center,
            //    center + (int)(100 * Math.Cos(valueAngle)),
            //    center + (int)(100 * Math.Sin(valueAngle)));

            Image img = Image.FromFile("c:\\pin.png");

            Matrix _mat = new Matrix();
            Point pnt = new Point(cx, cy);
            _mat.RotateAt(value,pnt);

            g.Transform = _mat;
            g.DrawImage(img, cx, cy);

            label1.Text = "VAL:" + value + "    Angle:" + valueAngle + "   Rad:";// +radian;
            label2.Text = " SIN:" + ((int)(100 * Math.Sin(valueAngle))) + "    COS:" + ((int)(100 * Math.Cos(valueAngle)));
            label2.Text += " X:" + (center + (int)(100 * Math.Sin(valueAngle))) + " Y:" + (center + (int)(100 * Math.Cos(valueAngle)));
        }

 

반응형