Rotation
-
are you really going to ask this question every day? -c
Be very, very careful what you put into that head, because you will never, ever get it out. --Thomas Cardinal Wolsey
-
are you really going to ask this question every day? -c
Be very, very careful what you put into that head, because you will never, ever get it out. --Thomas Cardinal Wolsey
-
First off, You need to use GDI+... rect is a RectF containing the position of where to draw the metafile. RotationXY is the rotation around the center of that rectange (in hundeths of a degree I think).
PointF destinationPoints[3]; PointF Origin; destinationPoints[0].X = (float)rect->GetLeft(); destinationPoints[0].Y = (float)rect->GetTop(); destinationPoints[1].X = (float)rect->GetRight(); destinationPoints[1].Y = (float)rect->GetTop(); destinationPoints[2].X = (float)rect->GetLeft(); destinationPoints[2].Y = (float)rect->GetBottom(); destinationPoints[3].X = (float)rect->GetRight(); destinationPoints[3].Y = (float)rect->GetBottom(); Origin.X = (rect->GetLeft()) + ((rect->Width)/2.0f); Origin.Y = (rect->GetTop()) + ((rect->Height)/2.0f); RotatePoints( destinationPoints, Origin, RotationXY, 3 ); graphics.DrawImage(&metafile, destinationPoints, 3);
and here is the RotatePoints function...
RotatePoints(PointF *point, PointF origin, T_DWORD RotationXY, int count) { double x, y, rad, crad, srad; #define PI (3.1415926535) //x' = (x * cos A) - (y * sin A) //y' = (x * sin A) + (y * cos A) rad = RotationXY; // in 0.01 degrees. rad = (rad * 2.0 * 3.1415926535)/36000.0; // change to radians. crad = cos( rad ); srad = sin( rad ); while( count > 0) { x = point->X - origin.X; y = point->Y - origin.Y; point->X = (float)(origin.X + ((x * crad) - (y * srad))); point->Y = (float)(origin.Y + ((x * srad) + (y * crad))); count--; point++; } }
Blade[DMS]
-
First off, You need to use GDI+... rect is a RectF containing the position of where to draw the metafile. RotationXY is the rotation around the center of that rectange (in hundeths of a degree I think).
PointF destinationPoints[3]; PointF Origin; destinationPoints[0].X = (float)rect->GetLeft(); destinationPoints[0].Y = (float)rect->GetTop(); destinationPoints[1].X = (float)rect->GetRight(); destinationPoints[1].Y = (float)rect->GetTop(); destinationPoints[2].X = (float)rect->GetLeft(); destinationPoints[2].Y = (float)rect->GetBottom(); destinationPoints[3].X = (float)rect->GetRight(); destinationPoints[3].Y = (float)rect->GetBottom(); Origin.X = (rect->GetLeft()) + ((rect->Width)/2.0f); Origin.Y = (rect->GetTop()) + ((rect->Height)/2.0f); RotatePoints( destinationPoints, Origin, RotationXY, 3 ); graphics.DrawImage(&metafile, destinationPoints, 3);
and here is the RotatePoints function...
RotatePoints(PointF *point, PointF origin, T_DWORD RotationXY, int count) { double x, y, rad, crad, srad; #define PI (3.1415926535) //x' = (x * cos A) - (y * sin A) //y' = (x * sin A) + (y * cos A) rad = RotationXY; // in 0.01 degrees. rad = (rad * 2.0 * 3.1415926535)/36000.0; // change to radians. crad = cos( rad ); srad = sin( rad ); while( count > 0) { x = point->X - origin.X; y = point->Y - origin.Y; point->X = (float)(origin.X + ((x * crad) - (y * srad))); point->Y = (float)(origin.Y + ((x * srad) + (y * crad))); count--; point++; } }
Blade[DMS]
-
I'm afraid that is the only solution I have found which does not involve stepping through the metafile and modifying each record manually. Blade[DMS]