0
서버 측에서 아래 코드를 사용하여 이미지를 회전 시키므로 5,10,20,.360과 같은 각도에서 제대로 작동합니다. 동일한 프로젝트에서 자바 응용 프로그램의 데이터베이스에 각도가 이미 저장된 이미지를 회전해야합니다. 여기에는 -1, -1.23,1.4543545 등의 값이 포함되어 있으며 아래 함수로는 회전하지 않습니다. 음의 값은 라디안처럼음수 값을 사용하여 이미지를 회전하는 방법
/업데이트 작업은 CODE
public static Bitmap rotateCenter(string imagepath,Bitmap bmpSrc, float theta)
{
Unit Width = 0;
Unit Height = 0;
if (imagepath.Contains("Images\\streets"))
{
if (imagepath.Contains("streets\\circle-4-way.png") || imagepath.Contains("streets\\circle_street.png"))
{
Width = Unit.Pixel(220);
Height = Unit.Pixel(220);
theta = theta + 10;
}
}
else
{
Width = Unit.Pixel(50);
Height = Unit.Pixel(30);
}
Double newdeg = theta * (180.0/Math.PI);
theta = (float)newdeg;
Matrix mRotate = new Matrix();
mRotate.Translate(Convert.ToInt32(Width.Value)/-2, Convert.ToInt32(Height.Value)/-2, MatrixOrder.Append);
mRotate.RotateAt(theta, new Point(0, 0), MatrixOrder.Append);
using (GraphicsPath gp = new GraphicsPath())
{ // transform image points by rotation matrix
gp.AddPolygon(new Point[] { new Point(0, 0), new Point(Convert.ToInt32(Width.Value), 0), new Point(0, Convert.ToInt32(Height.Value)) });
gp.Transform(mRotate);
PointF[] pts = gp.PathPoints;
// create destination bitmap sized to contain rotated source image
Rectangle bbox = boundingBox(bmpSrc, mRotate);
Bitmap bmpDest = new Bitmap(bbox.Width, bbox.Height);
using (Graphics gDest = Graphics.FromImage(bmpDest))
{ // draw source into dest
Matrix mDest = new Matrix();
mDest.Translate(bmpDest.Width/2, bmpDest.Height/2, MatrixOrder.Append);
gDest.Transform = mDest;
gDest.DrawImage(bmpSrc, pts);
gDest.DrawRectangle(Pens.Transparent, bbox);
//drawAxes(gDest, Color.Red, 0, 0, 1, 100, "");
return bmpDest;
}
}
}
감사합니다. 아래 라인은 나를 위해 일했습니다. double newdeg = theta * (180.0/Math.PI); theta = (float) newdeg; – Vani