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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:01:17+00:00 2026-06-13T19:01:17+00:00

I have an app that contains a picture box which updates images from a

  • 0

I have an app that contains a picture box which updates images from a live camera every time a new image gets loaded into the camera buffer. My problem is that whenever I’m getting this live feed, the whole app becomes very slow and (sometimes) unresponsive. I have a separate thread which basically does all the imaging steps and then puts the new image in the picture box. I’m kind of stuck on how to fix the issue and I’m wondering if anyone has any ideas? I’m not sure what kind of code you need but here is the ImageUpdated event that gets the image and sticks it on the PictureBox. Thanks for any help!

void CurrentCamera_ImageUpdated(object sender, EventArgs e)
{
    try
    {
        lock (CurrentCamera.image)
        {
            if (CurrentCamera != null && CurrentCamera.image != null && !changeCam)
            {
                videoImage = CurrentCamera.videoImage;
                if (CurrentCamera.videoImage != null && this.IsHandleCreated)
                {
                    Bitmap tmp = new Bitmap(CurrentCamera.image.Width, CurrentCamera.image.Height);
                    //Creates a crosshair on the image
                    using (Graphics g = Graphics.FromImage(tmp))
                    {
                        g.DrawImage(CurrentCamera.image, new Point(0, 0));
                        g.DrawLine(crosshairPen, new Point(CurrentCamera.image.Width / 2, 0), new Point(CurrentCamera.image.Width / 2, (CurrentCamera.image.Height)));
                        g.DrawLine(crosshairPen, new Point(0, CurrentCamera.image.Height / 2), new Point((CurrentCamera.image.Width), CurrentCamera.image.Height / 2));
                        g.DrawEllipse(crosshairPen, (CurrentCamera.image.Width / 2) - crosshairRadius, (CurrentCamera.image.Height / 2) - crosshairRadius, crosshairRadius * 2, crosshairRadius * 2);
                    }
                    pictureBox1.BeginInvoke((MethodInvoker)delegate
                    {
                        pictureBox1.Image = tmp;
                    });
                }
            }
        }
    }
    catch { }
}
  • 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-13T19:01:19+00:00Added an answer on June 13, 2026 at 7:01 pm

    In addition to the comment, I think that this might speed up a little bit. First, if the image is’t set on the pictureBox1, then don’t set another. Second, because of using pictureBox, it is optimized not to have flicker so you can draw the crosshair in your PaintEvent method handler for the pictureBox1. This is a little bit improved code that avoids double Bitmap drawing, then you should speed up as much as you can CurrentCamera_ImageUpdated method execution because new images come very fast, C# code can’t handle that much drawing even on a high performance machine. Start from here, and keep on improving.

        public Form1()
        {
            InitializeComponent();
            pictureBox1.Paint += new PaintEventHandler(pictureBox1_Paint);
        }
    
        void  pictureBox1_Paint(object sender, PaintEventArgs e)
        {
            if (pictureBox1.Image != null)
            {
                int width = pictureBox1.Image.Width;
                int height = pictureBox1.Image.Height;
                e.Graphics.DrawLine(crosshairPen, new Point(width / 2, 0), new Point(width / 2, height));
                e.Graphics.DrawLine(crosshairPen, new Point(0, pictureBox1.Image.Height / 2), new Point(width, height / 2));
                e.Graphics.DrawEllipse(crosshairPen, (width / 2) - crosshairRadius, (height / 2) - crosshairRadius, crosshairRadius * 2, crosshairRadius * 2);
            }
        } 
        IAsyncResult result = null;
        void CurrentCamera_ImageUpdated(object sender, EventArgs e)
        {
            try
            {
                lock (CurrentCamera.image)
                {
                    if (CurrentCamera != null && CurrentCamera.image != null && !changeCam)
                    {
                        videoImage = CurrentCamera.videoImage;
                        if (CurrentCamera.videoImage != null && this.IsHandleCreated)
                        {
                            if (result != null && result.IsCompleted)
                            {
                                result = pictureBox1.BeginInvoke((MethodInvoker)delegate
                                {
                                    pictureBox1.Image = CurrentCamera.videoImage;
                                });
                            }
                        }
                    }
                }
            }
            catch { }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web app that reads data from a SQL DB that contains
I've created an app which contains form and that have to filled up in
I have a Windows app that contains a browser control that loads pages from
I have an app that contains several activities...so lets say user is navigating activity
I have a view controller based app that contains several views that I display/hide
I have an app with a custom UITabBarController that contains five view controllers. Within
I have an App in my Device, that contains database, if I update that
in an app i have an entity that contains a list of other entities
I have a legacy intranet web app that was written for IE7 and contains
I have a .NET application that contains a checkbox (System.Windows.Forms.Checkbox). This component (WindowsForms10.BUTTON.app.0.378734a1) is

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.