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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:32:30+00:00 2026-06-07T10:32:30+00:00

i want to draw a line on a bmp image which is pass into

  • 0

i want to draw a line on a bmp image which is pass into a method using drawline method in C#

public void DrawLineInt(Bitmap bmp)
{

Pen blackPen = new Pen(Color.Black, 3);

int x1 = 100;
int y1 = 100;
int x2 = 500;
int y2 = 100;
// Draw line to screen.
e.Graphics.DrawLine(blackPen, x1, y1, x2, y2);
}

this give a error.So i want to know how to include paint event here
(PaintEventArgs e )

and also want to know how to pass parameters when we calling drawmethod?
example

DrawLineInt(Bitmap bmp);

this give the following error
“The name ‘e’ does not exist in the current context “

  • 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-07T10:32:32+00:00Added an answer on June 7, 2026 at 10:32 am

    “Draw a line on a bmp image which is pass into a method using drawline method in C#”

    PaintEventArgs e would suggest that you are doing this during the “paint” event for an object. Since you are calling this in a method, then no you do not need to add PaintEventArgs e anywhere.

    To do this in a method, use @BFree’s answer.

    public void DrawLineInt(Bitmap bmp)
    {
        Pen blackPen = new Pen(Color.Black, 3);
    
        int x1 = 100;
        int y1 = 100;
        int x2 = 500;
        int y2 = 100;
        // Draw line to screen.
        using(var graphics = Graphics.FromImage(bmp))
        {
           graphics.DrawLine(blackPen, x1, y1, x2, y2);
        }
    }
    

    The “Paint” event is raised when the object is redrawn. For more information see:

    http://msdn.microsoft.com/en-us/library/system.windows.forms.control.paint.aspx

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

Sidebar

Related Questions

I want to draw a line using controlpaint.DrawReversibleLine method and tried to pass system.windows.point,
i want to draw line, i have two textfiled in which i enter some
I want to draw line on iPad using user points. How can I do
I want to draw a line using CSS 3 and place it under an
i want to draw a line in core graphics in iphone.I am using Quartz
I want to draw a line between two views how it could possible using
is it possible to draw a line semi-transparent with image magick? i want to
I've one ImageView in which I want to draw a Line. I've done the
I want to draw a straight line in JFrame using Line2D.Double , also I
I want to draw line on image view then image view is to put

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.