Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8452833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:36:19+00:00 2026-06-10T11:36:19+00:00

I am using Graphics on a Panel to generate a spirograph, but when I

  • 0

I am using Graphics on a Panel to generate a spirograph, but when I try to save the drawing as a BMP (or whatever file extension), the file only takes the background of the panel, but the spirograph is not there! Anyone knows a way around?

        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();
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T11:36:20+00:00Added an answer on June 10, 2026 at 11:36 am

    You cannot save bitmaps directly from the Graphics object of the Panel.

    First, you have to create a Bitmap object and derive Graphics from it.
    Then, once the drawing is finished, you can reuse the bitmap as you wish : either save it to the disk or show it in a picturebox, or both !

    This article will show you detailed information about how to do this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I resized an image using Java2D Graphics class. But it doesn't look right. BufferedImage
I have a program that draws some vector graphics using System.Drawing and the Graphics
I try to draw rain and snow as particle system using Core Graphics .
I understand Objective-C memory management but I'm using Core Graphics functionality such as CGRect,
I am using the following code to set background image to a panel. But
I am trying to draw a line using the Graphics 2D but then the
I am having trouble with the Graphics that I am drawing on a Panel
I can't get graphics/text to draw on my panel/canvas/window in my Java program (using
I want to draw string using Graphics with Rectangle border outside the string. This
I resized the picture into 100x100 size by using Graphics class and drawImage() method.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.