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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:44:32+00:00 2026-06-03T04:44:32+00:00

I am making an XNA application where I capture the screenshot from a webcam

  • 0

I am making an XNA application where I capture the screenshot from a webcam 4 times a second and then I try to convert it into an Boolean array when the pixel color Red is below a certain threshold. When I convert it into a Texture2D it doesn’t lag but when I try to get the individual pixels it does lag, even when the webcam resolution is 176×144.

This is the code to grab the Bitmap:

public Bitmap getBitmap()
    {
        if (!panelVideoPreview.IsDisposed)
        {
            Bitmap b = new Bitmap(panelVideoPreview.Width, panelVideoPreview.Height, PixelFormat.Format32bppRgb);
            using (Graphics g = Graphics.FromImage(b))
            {
                Rectangle rectanglePanelVideoPreview = panelVideoPreview.Bounds;
                Point sourcePoints = panelVideoPreview.PointToScreen(new Point(panelVideoPreview.ClientRectangle.X, panelVideoPreview.ClientRectangle.Y));
                g.CopyFromScreen(sourcePoints, Point.Empty, rectanglePanelVideoPreview.Size);
            }

            return b;
        }
        else
        {
            Bitmap b = new Bitmap(panelVideoPreview.Width, panelVideoPreview.Height);
            return b;
        }
    }

This is the code to convert the Bitmap to a Boolean array:

public bool[,] getBoolBitmap(uint treshold)
    {
        Bitmap b = getBitmap();

        bool[,] ar = new bool[b.Width, b.Height];

        for (int y = 0; y < b.Height; y++)
        {
            for (int x = 0; x < b.Width; x++)
            {
                if (b.GetPixel(x, y).R < treshold)
                {
                    ar[x, y] = false;
                }
                else
                {
                    ar[x, y] = true;
                }
            }
        }

        return ar;
    }
  • 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-03T04:44:33+00:00Added an answer on June 3, 2026 at 4:44 am

    The answer provided by Hans Passant is correct, it is better to use LockBits and process the data all at once.

    You might also try writing a shader that thresholds the data and thereby utilize the power of the GPU to parallel-process the input image stream much, much faster.

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

Sidebar

Related Questions

I'm making a simple game using the Windows Phone Silverlight and XNA Application type
I'm learning F#, and decided to try making simple XNA games for windows using
I'm making a drum machine. From what I've read, it looks like the XNA
I'm making a simple 2 player game in XNA and started looking into saving
I'm making a Tetris Clone in C# with XNA, and I'm unsure of how
I'm making the skeleton for the typical BubbleShooter game in XNA, and I'm having
(Sorry if I missed the answer) So I just started out making an XNA
I am making a game using C# with the XNA framework. The player is
I'm following this tutorial attempting to learn XNA, but I'm having issues making my
I am making a physics engine in c# / XNA, I have three basic

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.