を使用Graphics
してPanel
スピログラフを生成していますが、図面を BMP (または任意のファイル拡張子) として保存しようとすると、ファイルはパネルの背景のみを取得しますが、スピログラフはそこにありません! 誰でも方法を知っていますか?
int rayonA = Convert.ToInt32(txtCercleFixe.Text);
int rayonB = Convert.ToInt32(txtCercleNonFixe.Text);
int distance = Convert.ToInt32(txtPenDistance.Text);
int pointsParCourbe = Convert.ToInt32(txtPointsParCourbe.Text);
int TypeCourbe = 0;
Graphics dessin = pnlSpiro.CreateGraphics();
public void DessinHypotrochoid(ref Graphics dessin, PointF ptOrigin, int rayonA, int rayonB, int distance, int pointParCourbe, int PFC, int rouge, int vert, int bleu,bool random)
{
// Dim angleStep As Double = radiansPerCircle / PointsPerCurve
double angleStep = radians / pointParCourbe;
//' Compute number of revolutions.
//Dim NumRevolutions As Integer = (bRadius / HighestCommonFactor(Math.Round(aRadius), Math.Round(bRadius)))
int NumRevolution = rayonB / PFC;
//' Total number of points to generate
//Nombre de points totaux à générer
//Dim NumPoints As Integer = PointsPerCurve * NumRevolutions
int NumPoints = pointParCourbe * NumRevolution;
//Dim oldPoint As New PointF( _
// ptOrigin.X + aRadius - bRadius + distance, ptOrigin.Y)
PointF oldPoint = new PointF((ptOrigin.X + rayonA - rayonB + distance), ptOrigin.Y);
//Dim angle As Double = 0
double angle = 0;
//Dim aMinusb As Double = aRadius - bRadius
double aMoinsB = rayonA - rayonB;
//Dim aMinusbOverb As Double = aMinusb / bRadius
double aDiviseB = aMoinsB / rayonB;
//Dim pt As Integer
//For pt = 0 To NumPoints - 1
// On fait le dessin.
for (int pt = 0; pt <= NumPoints; pt += 1)
{
angle += angleStep;
PointF newPoint = new PointF((float)(ptOrigin.X + aMoinsB * Math.Cos(angle) + distance * Math.Cos(angle * aDiviseB)),(float)(ptOrigin.Y + aMoinsB * Math.Sin(angle) - distance * Math.Sin(angle * aDiviseB)));
if (pt == 0)
{
oldPoint = newPoint;
}
if (random == false)
{
Pen Pinceau = new Pen(Color.FromArgb(rouge, vert, bleu), 1);
dessin.DrawLine(Pinceau, oldPoint, newPoint);
}
else
{
Random r = new Random();
Pen Pinceau = new Pen(Color.FromArgb(r.Next(0, 256), r.Next(0, 256), r.Next(0, 256)), 1);
dessin.DrawLine(Pinceau, oldPoint, newPoint);
}
oldPoint = newPoint;
}
dessin.Flush();
dessin.Dispose();
}