Question Picturebox.BackgroundImage rendering speed huge difference from 32bit to 64bit

Regmaster

Member
Joined
Oct 25, 2024
Messages
7
Programming Experience
10+
Hi All, I'm Daniele and have a problem during showing an image using the backgroundImage property of a Windows Form picture box object.
A camera send me a frame each 100 milliseconds, and the same code compiled 32bit, take about 120 millisecond to show the image into the picturebox; simply compile same code with 64bit, the frame arrived in the same way every 100 milliseconds, but takes about 1700 milliseconds to be showed into the picture box...Why this huge difference?? Exist a work around?
Thanks in advance for help!
 
Solution
Anyway, if you can do the painting yourself instead of relying on the picture box, it runs much faster:
C#:
using System;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;

namespace ImageRenderTest
{
    class Program : Form
    {
        const int StripeHeight = 20;
        int m_offset = 0;
        readonly Stopwatch m_paintStopWatch = new Stopwatch();
        readonly Stopwatch m_renderStopWatch = new Stopwatch();

        Bitmap RenderBitmap()
        {
            int width = ClientRectangle.Width;
            int height = ClientRectangle.Height;
            var bitmap = new Bitmap(width, height);
            using (var g = Graphics.FromImage(bitmap))
            {
                int red = m_offset...
Back
Top Bottom