I have to download a webcam image via http and refresh it at 10 fps and display it on a WPF window Will happen. Right now I am using this code:
windows 1 wndMain; Bitmap image img; Dispatcher Timer TMR Refresh; Public WCam (Window 1 wndMain, String Immiguri) {this.wndMain = wndMain; This.MouseLeftButtonDown + = Representative {DragMove (); }; Url = imgery; InitializeComponent (); TmrRefresh = New Dispatcher Timer (TimespainFromMilisceconds (100), Dispatcher Advance. Normal, Refresh, Dispatcher. Current Illustrator); } Private Zero Windows_Loaded (Object Sender, RoutedEventArgs e) {if (url! = "") {Try {img = new bitmapImage ()} img.BeginInit (); Img.CacheOption = BitMapApplication Download; Img.CreateOptions = BitmapCreateOptions.IgnoreImageCache; Img.UriSource = (new URI); Img.EndInit (); } Hold (exception pre) {new WPopup (). Show (ex.Message); } ImgBox.Source = img; TmrRefresh.Start (); }} Public Zero Refresh (Object Sender, EventAurge E) {try {img = new bitmapImage ()} img.BeginInit (); Img.CacheOption = BitMapApplication Download; Img.CreateOptions = BitmapCreateOptions.IgnoreImageCache; Img.UriSource = (new URI); Img.EndInit (); } Hold (exception pre) {new WPopup (). Show (ex.Message); } ImgBox.Source = null; ImgBox.Source = img; }
It does not show anything, if I increase the timer interval to 1000 then it displays the image, but the image is removed, while it loads the next one I may slow down the window gradually, even if it loads.
Separate the loading logic from the image Keep the code loaded in the same way, refreshing the image You should request to keep a simple async (run UI) and only when finished, change the image source to local memory.
Comments
Post a Comment