通过外部接口快速显示图像 [英] Displaying images fast via external interface

查看:43
本文介绍了通过外部接口快速显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我已经在VB.NET中编写了一个应用程序,通过外部触发器在DoubleBuffered面板上显示图像 - 为简单起见,我们假设它使用一个只需要一个数字的串口和相应的图像显示数字。



目前,这是一个文件名数组,因此图像文件是即时而不是某种缓存加载的。



原因是我可能有几百张图片,但它们相对较小<每个100kb。我一次只能使用少数几个,但我不知道哪一个。



该程序工作正常,但它仍然没有完全符合我的要求。



我遇到的问题是,在交换图像时,屏幕会在显示新图像之前闪烁为黑色。这是非常小的,但我正在尝试用它做一些动画类型的东西,一些图像只显示100ms左右。



理想情况下,我想要的是关于如何在没有闪烁的情况下快速显示这些图像的一些想法。



我想到的一个想法是在彼此的顶部有2个双缓冲面板并交替更新图像,然后在更新后将每个面板带到前面。我认为这会更顺畅,但我怀疑这是最好的方法。



我不是在跟任何人为我编写代码,只是为了实现我想要实现的目标的最佳方式提出一些想法。



任何帮助都将不胜感激。

Hi all, I have written an app in VB.NET to display images on a DoubleBuffered panel via an 'external' trigger - For simplicity sake, lets say it uses a serial port that just takes a number and the image corresponding to the number is displayed.

At the moment, that is an array of filenames so the image file is loaded 'on the fly' rather than in some sort of cache.

The reason for this is that I potentially have a few hundred images but they are relatively small < 100kb each. I may use only a handful at a time but I do not know which ones.

The program works 'ok' but it's still not doing exactly what I want.

The issue I have is that when swapping images, the screen flickers to black before the new image is displayed. It's very minor but I'm trying to do some animation type stuff with it and some images are only displayed for 100ms or so.

Ideally, what I would like is some ideas on how I can display these images super fast and without the flicker.

One Idea I did have was to have 2 double buffered panels over the top of each other and update the images alternatively and then 'bring to front' each panel after it has updated. I presume that this would be smoother but I doubt that is the best way to do it.

I'm not after anyone to write code for me, just to throw some ideas around on the best way to accomplish what I want to achieve.

Any help would be appreciated.

推荐答案

您是否将图片直接设置为panel backgroundimage属性。如果你是,那么这可能就是问题所在。尝试使用图形对象将图像绘制到控件。
are you setting the picture directly to the panels backgroundimage property. if you are, then this is probably the problem. try using the graphics object to paint the image to the control.


非常感谢你 - 简单而又烦人的东西!



我正在使用:

Thank you so much for that - Something simple yet very annoying!

I was using:
Me.BackgroundImage = Image.FromFile(App_Path() & "Images\" & imageNames(i - 1))





并将其更改为:



and changed it to:

Dim newImage As Image = Image.FromFile(App_Path() & "Images\" & imageNames(i - 1))
Dim formGraphics As Graphics = Me.CreateGraphics
formGraphics.DrawImage(newImage, 0, 0)
newImage.Dispose()





现在它工作得非常漂亮!



And now it works beautifully!


这篇关于通过外部接口快速显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆