简体   繁体   English

如何从硬盘加载图像并在带定时器的图片框中显示它们?

[英]How can I load images from the hard disk and display them in pictureBox with timer?

private void timer1_Tick(object sender, EventArgs e)
        {
            foreach (string image in filesRadar)
            {
                pictureBox1.Load(image);
            }
        }

        private void timer2_Tick(object sender, EventArgs e)
        {
            foreach (string image in filesSatellite)
            {
                pictureBox2.Load(image);
            }
        }

I'm not getting any errors/exceptions and using breakpoint it stop on the Load line/s but it's not showing the images on any of the pictureBoxes.我没有收到任何错误/异常,并使用断点在 Load line/s 上停止,但它没有在任何图片框上显示图像。

This is working.这是有效的。 could be in other ways but it's working.可能有其他方式,但它正在起作用。

        int radImagesCount = 0;
        private void timer1_Tick(object sender, EventArgs e)
        {
            radImagesCount++;

            if (radImagesCount == filesRadar.Length)
            {
                radImagesCount = 0;
            }

            pictureBox1.Image = new Bitmap(filesRadar[radImagesCount]);
        }

        int satImagesCount = 0;
        private void timer2_Tick(object sender, EventArgs e)
        {
            satImagesCount++;

            if (satImagesCount == filesSatellite.Length)
            {
                satImagesCount = 0;
            }

            pictureBox2.Image = new Bitmap(filesSatellite[satImagesCount]);
        }

Both filesRadar and filesSatellite are string[] arrays contains the images fils. filesRadar 和 filesSatellite 都是包含图像文件的 string[] 数组。

暂无
暂无

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

相关问题 如何从硬盘获取图像,调整图像大小并将其添加到列表中 <image> 快速? - How can i get images from the hard disk resize the images and add them to a list<image> fast? 如何解析来自谷歌的图像并将它们显示到图片框中? - How do I parse images from google and display them into a pictureBox? 如何从网站下载图像到我的硬盘? - How can I download the images from the site to my hard disk? 如何使计时器向前或向后更改pictureBox1中显示的图像? - How can I make timer that will change the images display in pictureBox1 forward or backward? 我可以从word文件中检索图像和形状,并在C#的PictureBox控件中显示它们吗? - Can i retrieve images and shapes from word file and display them in PictureBox control of C#? 使用mimekit.mimemessage从硬盘加载eml文件如何只加载文本? - Using mimekit.mimemessage to load eml files from hard disk how can I load only text? 我正在尝试从网站获取图像列表,并将它们保存到硬盘但它不起作用 - I'm trying to get a list of images from website and also save them to hard disk but it doesn't work 如何对FileInfo []中的文件进行排序,然后将硬盘中的最后一个Gif文件从FileInfo []分配给pictureBox1? - How do i sort the files in FileInfo[] and then assign the last Gif file from the hard disk from FileInfo[] to pictureBox1? 如何将一些bat文件添加到我的项目中,这样我就不再需要硬盘上的文件了? - How can i add some bat files to my project so i will not need them anymore on the hard disk? 从现有图像创建图像并将其显示在PictureBox中 - Create Images from existing image and display them in a PictureBox
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM