Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

how to use image control to display 10 images sequentially?

$
0
0

I have struggled with this problem the whole day.

when I use this code, it can work:

int i = 0;

        private void button1_Click(object sender, RoutedEventArgs e)
        {
           i++;
                BitmapImage bi = new BitmapImage();
                bi.BeginInit();
                bi.UriSource = new Uri(@"D:\desktop\program\exercise\Solution6\WpfApplication1\bin\x64\Debug\zx" + i + ".jpg", UriKind.Absolute);
                bi.EndInit();
                image1.Source = bi;


        }

but when I use this code, it can only display the last image:

private void button1_Click(object sender, RoutedEventArgs e)
        {

            for (int i = 0; i < 10; ++i )
            {
                BitmapImage bi = new BitmapImage();
                bi.BeginInit();
                bi.UriSource = new Uri(@"D:\desktop\program\exercise\Solution6\WpfApplication1\bin\x64\Debug\zx" + i + ".jpg", UriKind.Absolute);
                bi.EndInit();
                image1.Source = bi;
            }

        }

Please tell me how to solve it, I just want to use image control to display frame from camera sequentially.


Viewing all articles
Browse latest Browse all 18858

Trending Articles