private void Button_Imaging_ImportGif_Click(object sender, RoutedEventArgs e) { var s = new System.Diagnostics.Stopwatch(); s.Start(); OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Image Files(*.GIF)|*.GIF"; if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { GifPlayPause = false; ImageProcesser.DisposeGif(); ImageProcesser.DisposeStill(); if (ImageProcesser.LoadGifFromDisk(openFileDialog.FileName)) { ContentBitmap = MatrixFrame.CreateBitmapSourceFromBitmap(ImageProcesser.WorkingBitmap); MatrixFrame.BitmapToFrame(ImageProcesser.WorkingBitmap, ImageProcesser.InterpMode); IMXMax = IMX2 = ImageProcesser.LoadedGifImage.Width; IMYMax = IMY2 = ImageProcesser.LoadedGifImage.Height; IMX1 = 0; IMY1 = 0; //FrameToPreview(); //SerialManager.PushFrame(); ImageProcesser.ImageLoadState = ImageProcesser.LoadState.Gif; ResetSliders(); } else { System.Windows.MessageBox.Show("Cannot load image."); } } // System.Windows.MessageBox.Show(s.ElapsedMilliseconds.ToString()); }
private void Button_Imaging_ImportImage_Click(object sender, RoutedEventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Image Files(*.BMP;*.JPG;*.PNG;*.GIF)|*.BMP;*.JPG;*.PNG;*.GIF"; if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { IMLockDim = false; GifPlayPause = false; ImageProcesser.DisposeStill(); ImageProcesser.DisposeGif(); if (ImageProcesser.LoadBitmapFromDisk(openFileDialog.FileName)) { ContentBitmap = MatrixFrame.CreateBitmapSourceFromBitmap(ImageProcesser.WorkingBitmap); MatrixFrame.BitmapToFrame(ImageProcesser.WorkingBitmap, ImageProcesser.InterpMode); IMXMax = IMX2 = ImageProcesser.WorkingBitmap.Width; IMYMax = IMY2 = ImageProcesser.WorkingBitmap.Height; IMX1 = 0; IMY1 = 0; //FrameToPreview(); //SerialManager.PushFrame(); ImageProcesser.ImageLoadState = ImageProcesser.LoadState.Still; ResetSliders(); } else { System.Windows.MessageBox.Show("Cannot load image."); } } }
private void RefreshStillImage() { if (ImageProcesser.ImageLoadState == ImageProcesser.LoadState.Still) { ImageProcesser.DisposeWorkingBitmap(); ImageProcesser.WorkingBitmap = ImageProcesser.CropBitmap(ImageProcesser.LoadedStillBitmap, ImageProcesser.ImageRect); ContentBitmap = MatrixFrame.CreateBitmapSourceFromBitmap(ImageProcesser.WorkingBitmap); MatrixFrame.BitmapToFrame(ImageProcesser.WorkingBitmap, ImageProcesser.InterpMode); //FrameToPreview(); //SerialManager.PushFrame(); } }
private void GifTimer_Tick(object sender, EventArgs e) { ImageProcesser.DisposeWorkingBitmap(); if (_gifFrameIndex >= ImageProcesser.LoadedGifFrameCount - 1) { _gifFrameIndex = 0; } else { _gifFrameIndex++; } ImageProcesser.LoadedGifImage.SelectActiveFrame(ImageProcesser.LoadedGifFrameDim, _gifFrameIndex); ImageProcesser.WorkingBitmap = ImageProcesser.CropBitmap(new Bitmap(ImageProcesser.LoadedGifImage), ImageProcesser.ImageRect); ContentBitmap = MatrixFrame.CreateBitmapSourceFromBitmap(ImageProcesser.WorkingBitmap); MatrixFrame.BitmapToFrame(ImageProcesser.WorkingBitmap, ImageProcesser.InterpMode); ImageProcesser.DisposeWorkingBitmap(); //SerialManager.PushFrame(); }
private void RefreshGifImages() { if (ImageProcesser.ImageLoadState == ImageProcesser.LoadState.Gif) { ImageProcesser.DisposeWorkingBitmap(); if (GifPlayPause != true) //if gif is not playing { if (_gifFrameIndex > ImageProcesser.LoadedGifFrameCount - 1) { _gifFrameIndex = 0; } ImageProcesser.WorkingBitmap = ImageProcesser.CropBitmap(new Bitmap(ImageProcesser.LoadedGifImage), ImageProcesser.ImageRect); ContentBitmap = MatrixFrame.CreateBitmapSourceFromBitmap(ImageProcesser.WorkingBitmap); MatrixFrame.BitmapToFrame(ImageProcesser.WorkingBitmap, ImageProcesser.InterpMode); //FrameToPreview(); //SerialManager.PushFrame(); } } }