在vb.net中查看图像 [英] image viewing in vb.net

查看:75
本文介绍了在vb.net中查看图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在vb.net的图片框控件中交替更改图像?

how to change image alternatively in picturebox control in vb.net?

推荐答案

显然,通过为其属性Image分配替代值,http://msdn.microsoft.com/en-us/library/system.windows. forms.picturebox.image.aspx [ ^ ].

这样就很简单了.

万一您需要比这还要复杂的东西,请考虑完全不使用PictureBox.相反,请查看我过去的答案:
如何从旧图纸中清除面板 [ ^ ],
在C#中绘制矩形 [ Paint是一种哪种好玩的方法? (DataGridViewImageCell.Paint(...)) [在mdi子表单之间画线 [在面板上捕获图形 [ Control.Invoke()与Control.BeginInvoke() [ ^ ],
Treeview扫描仪和MD5的问题 [如何获取keydown事件在vb.net中的不同线程上操作 [启用禁用+多线程后控件事件不会触发 [ ^ ].

—SA
Apparently, by assigning alternative values to its property Image, http://msdn.microsoft.com/en-us/library/system.windows.forms.picturebox.image.aspx[^].

This is simple enough to do it in this way.

In case you will need something even a bit more complex than that, consider not using PictureBox at all. Instead, see my past answers:
How do I clear a panel from old drawing[^],
draw a rectangle in C#[^].

See also:
What kind of playful method is Paint? (DataGridViewImageCell.Paint(...))[^],
Drawing Lines between mdi child forms[^],
capture the drawing on a panel[^].



If you need periodic flipping of the image, I should warn you: it will irritate most of the users very much, so it''s the best to avoid it.

Don''t use System.Windows.Forms.Timer: it is too bad, won''t behave periodically. Other two timers types are good enough enough, but a separate thread with periodic flip and Sleep is much easier and more reliable. In both timer and thread cases, your handler will be called from some non-UI thread, and you cannot call anything related to UI from non-UI thread. Instead, you need to use the method Invoke or BeginInvoke of System.Windows.Threading.Dispatcher (for both Forms or WPF) or System.Windows.Forms.Control (Forms only).

You will find detailed explanation of how it works and code samples in my past answers:
Control.Invoke() vs. Control.BeginInvoke()[^],
Problem with Treeview Scanner And MD5[^].

See also more references on threading:
How to get a keydown event to operate on a different thread in vb.net[^],
Control events not firing after enable disable + multithreading[^].

—SA


使用计时器可在图片框中交替更改图片.
在计时器内写:
t = t + 1
如果t = 2那么

PictureBox1.Image = Image.FromFile(图像路径")
如果结束

如果t = 5那么
PictureBox1.Image = Image.FromFile(图像路径")

如果结束

如果t = 8那么
t = 0
如果结束
Use a timer to change picture alternatively in picturebox.
Write inside a timer:
t = t + 1
If t = 2 Then

PictureBox1.Image = Image.FromFile("Image Path")
End If

If t = 5 Then
PictureBox1.Image = Image.FromFile("Image Path")

End If

If t = 8 Then
t = 0
End If


这篇关于在vb.net中查看图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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