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

  • Home
  • SEARCH
  • 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 9181923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:26:14+00:00 2026-06-17T18:26:14+00:00

I know several methods for reading Bitmap pixels or to get a Graphic object

  • 0

I know several methods for reading Bitmap pixels or to get a Graphic object from an image, but what I am trying to understand is how to know what pixels have been drawn by the user by means of a Graphics object. Example: the user draw a line (but it could be any possible shape) using something like:

surface.DrawLine(aPen, X0, Y0, X1, Y1);      

I need to know what pixels have been set by the user to perform some processing. This could be done quite easily for simple shapes using math (i.e. X = X0 + (X1-X0)*t) , but it seems to me possibly unefficient (specially for complex shapes). A solution I would like is to read a Bitmap looking for the pixels that have been set, but I do not know methods for getting a Bitmap image (or whatever relevant data structure) to work on from a Graphics object. Because this is an obvious need for any program allowing to the user do draw, I am for sure missing some points. Someone has a hint about this?

P.S. I am using Graphics object over a 8Bpp indexed Bitmap in a Windows Form and I need all the pixel coordinates and, possibly, the pixel values (they could be deduced from pixel coordinates, I guess)

Proposed solution

The best solution I can figure out after the contributions in this post is something similar to this (being sourceImage the image I want to draw on and surface the picturebox control where sourceImage is rendered):

         private void DrawOverlay()
        {
            using (var tmpImg = new Bitmap (SourceImage.Width,SourceImage.Height, PixelFormat .Format32bppArgb))
            {
                var g = Graphics.FromImage(tmpImg);
                g.DrawLine(pen1, Startx, Starty, Endx, Endy);
                tmpImg.MakeTransparent(Color.FromArgb(0, 0, 0));
                surface.DrawImage(tmpImg, new Point (0, 0));      

// process here the tmpImg  pixels drawn by the user 

            }                 
        }

If someone has better answer, please, if you like, let us know; otherwise I’ll close the post answering to my own question as above.

  • 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-17T18:26:16+00:00Added an answer on June 17, 2026 at 6:26 pm

    As far as I know the proposed solution draft in the question after the feedback received seems to be the an acceptable solution to have an easy access to the pixels drawn.

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

Sidebar

Related Questions

After reading several webpages about networking, in attempt to trying to understand basic networking,
I know there are several threads asking similar questions - but I havent found
I know there are several questions about satellite Assembly's out there, but I still
I know there are several libraries to connect to XMPP servers, but is there
All right, do not get angry now, I know there are several questions about
I know this has been asked different ways several times, but I'm just not
I know this question is similar to several previous ones, but I can't find
I have a class that extends RemoteServiceServlet. This class has several methods, in one
I have several methods that I need to wrap in new methods in basically
I have a class Foo which has several methods like button_0_0 , button_0_1 ,

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.