简体   繁体   English

C#将位图快速加载到PictureBox中

[英]C# Fast load Bitmap into PictureBox

I receve Bitmap image from a camera at 30 fps, and I need to display all images in a pictureBox. 我以30 fps的速度从相机接收位图图像,并且需要在pictureBox中显示所有图像。
The problem is that the PictureBox is very slow! 问题在于PictureBox非常慢!
I have try to implement a custom PictureBox with DoubleBuffer enabled but the problem is not resolved. 我尝试使用启用DoubleBuffer的方法来实现自定义PictureBox,但问题仍未解决。
Do you have a custom PictureBox or an user control or a solution that can display the image faster? 您是否具有可更快显示图像的自定义PictureBox或用户控件或解决方案?

Additional information: 附加信息:
The image resolution is 2048x1088 with 256 graylevel (8bit image). 图像分辨率为2048x1088,具有256灰度(8位图像)。
I use AForge.NET for elaborate the images. 我使用AForge.NET制作图像。

Thank you 谢谢

That image gets expensive to draw when it has to be resized to fit the PB's client area. 当必须调整大小以适应PB客户区域时,绘制该图像的成本很高。 Which is very likely in your case because your images are pretty large. 在您的情况下,很有可能是因为您的图像很大。 It uses a high-quality bi-cubic filter to make the resized image look good. 它使用高质量的双三次滤镜使调整大小后的图像看起来不错。 That's pretty expensive, albeit that the result is good. 尽管结果很好,但是那是相当昂贵的。

To avoid that expense, resize the image yourself before assigning it to the Image property. 为避免该费用,请在将图像分配给Image属性之前自行调整其大小。 Make it just as large as the PB's ClientSize. 使它与PB的ClientSize一样大。

That's going to make a big difference in itself. 这本身将产生很大的变化。 The next thing you can do is to create the scaled bitmap with the 32bppPArgb pixel format. 下一步,您可以使用32bppPArgb像素格式创建缩放的位图。 It's the format that's about 10 times faster then any other because it matches the video adapter on most machines so no pixel format conversions are necessary. 这种格式比其他格式快10倍左右,因为它与大多数计算机上的视频适配器匹配,因此不需要像素格式转换。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM