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 1018005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:47:31+00:00 2026-05-16T10:47:31+00:00

How can I transfer the values of my graphics to a bitmap so I

  • 0

How can I transfer the values of my graphics to a bitmap so I can save it as jpg or bmp file.

here’s my code:

private void pictureBox1_Paint_1(object sender, PaintEventArgs e)
    {
       using(var p = new Pen(Color.Blue, 4)){
           for (int i = 0; i < _listPS.Count; i++)
           {
            e.Graphics.DrawLine(_pen, _listPS[i], _listPE[i]);
           }
       }
    }

suppose that _listPS and _listPE have values.

ah! Solved it LOL! 🙂
Here’s my solution:

private Bitmap _mybitmap;
private void pictureBox1_Paint_1(object sender, PaintEventArgs e)
    {   
        _mybitmap = new Bitmap(pictureBox1.Width, pictureBox1.Heigth);
        Graphics _tempg = Graphics.FromImage(_mybitmap);

       using(var p = new Pen(Color.Blue, 4){
           for (int i = 0; i < _listPS.Count; i++)
           {
               e.Graphics.DrawLine(_pen, _listPS[i], _listPE[i]);
               _tempg.DrawLine(_pen, _listPS[i], _listPE[i]);
           }

           _tempg.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-05-16T10:47:32+00:00Added an answer on May 16, 2026 at 10:47 am

    Try this one

    Bitmap _image = new Bitmap(100, 100);
    Graphics _g = Graphics.FromImage(_image);
    
    //Graphics _g = pictureBox1.CreateGraphics();
    Pen _pen = new Pen(Color.Red, 3);
    Point myPoint1 = new Point(10, 20);
    Point myPoint2 = new Point(30, 40);
    
    for (int i = 0; i < _listPS.Count; i++)
    {
        _g.DrawLine(_pen, _listPS[i], _listPE[i]);
    }
    
    _image.Save(@"D:\test.bmp");
    _image.Dispose();
    _g.Dispose();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In C (UNIX), how can I transfer and receive a file in multiple blocks
I've some code I use to transfer a table1 values to another table2 ,
As I know, I can use global variable transfer the value among the multi
How can I transfer specific rows from one MySQL DB on one server to
I have two Database, DB1 and DB2. How can I transfer data of DB1
How can I perform a redirect with Server.Transfer() to the same page that is
How can I set an object property given its name in a string? I
How can I pass values from one form to another in Asp.net? Can you
Im running into this error that I can't work out Im writing some code
I need to transfer the values from a PHP array into a JavaScript array

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.