从Winforms图片框中的url加载的图像是否存储在缓存中? [英] Is the image loaded from url in winforms picturebox stored in cache?
问题描述
在winform应用程序的表单中,我必须显示存储在Web服务器上的图像(多幅图像).显示图像没有问题,因为我可以简单地将URL分配给图片框.
In a form in winform application i have to show images (multiple images) stored on webserver. There is no problem in showing images as i can simple assign URL to picturebox.
picturebox1.ImageLocation = "http://example.com/Image.jpg";
该表单将被频繁打开多次,现在每次打开表单时,每次都会下载图像.不必要增加流量.
That form will be opened many times frequently, right now each time form is opened, images are being downloaded every time. It is unnecessary increasing traffic.
是否可以告诉picturebox缓存图像(就像Browser一样),因此下次请求相同的图像时,应该快速加载. 有可能吗?
Is it possible to tell picturebox to cache image (as Browser do), so next time same images is requested, it should load quickly. Is that possible?
推荐答案
使用
预加载图像
Image img = Image.FromFile("...");
Pre-load the image(s) with
Image img = Image.FromFile("...");
然后您可以将图像提供给PictureBox:
pictureBox1.Image = img;
Then you can give the image to the PictureBox:
pictureBox1.Image = img;
这篇关于从Winforms图片框中的url加载的图像是否存储在缓存中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!