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 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());
        }
 void StartSerialSyncCapture()
 {
     _fpsStopWatch = Stopwatch.StartNew();
     SerialManager.SerialAcknowledged += OnSerialAcknowledged;
     MatrixFrame.InjestGDIBitmap(ScreenRecorder.ScreenToBitmap(), ScreenRecorder.InterpMode);
     //    Dispatcher.Invoke(() => { FrameToPreview(); });
     SerialManager.PushFrame();
 }
Example #4
0
 void FFTCallback(float[] fftData) //data received
 {
     Dispatcher.Invoke(() =>
     {
         MatrixFrame.FFTToFrame(fftData);
         //FrameToPreview();
         SerialManager.PushFrame();
     });
 }
 void OnSerialAcknowledged()
 {
     if (SyncSerial == true)
     {
         MatrixFrame.InjestGDIBitmap(ScreenRecorder.ScreenToBitmap(), ScreenRecorder.InterpMode);
         //     Dispatcher.Invoke(() => { FrameToPreview(); });
         SerialManager.PushFrame();
         LocalFPS             = SerialFPS = _fpsStopWatch.ElapsedMilliseconds - _localPreviousMillis;
         _localPreviousMillis = _fpsStopWatch.ElapsedMilliseconds;
     }
 }
 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();
     }
 }
        void PixelDataCallback(Bitmap capturedBitmap)
        {
            LocalFPS             = _fpsStopWatch.ElapsedMilliseconds - _localPreviousMillis;
            _localPreviousMillis = _fpsStopWatch.ElapsedMilliseconds;

            MatrixFrame.InjestGDIBitmap(capturedBitmap, ScreenRecorder.InterpMode);

            //     Dispatcher.Invoke(() => { FrameToPreview(); });

            if (SerialManager.PushFrame())
            {
                SerialFPS             = _fpsStopWatch.ElapsedMilliseconds - _serialPreviousMillis;
                _serialPreviousMillis = _fpsStopWatch.ElapsedMilliseconds;
            }
            //GC.Collect();
        }
Example #8
0
        void DrawPixel()
        {
            if (Mouse.LeftButton == MouseButtonState.Pressed)
            {
                System.Windows.Point pos = Mouse.GetPosition(MatrixImage);

                int x = (int)(pos.X / MatrixImage.ActualWidth * MatrixFrame.Width);
                int y = (int)(pos.Y / MatrixImage.ActualHeight * MatrixFrame.Height);

                x = x > MatrixFrame.Width - 1 ? MatrixFrame.Width - 1 : x < 0 ? 0 : x;
                y = y > MatrixFrame.Height - 1 ? MatrixFrame.Height - 1 : y < 0 ? 0 : y;

                MatrixFrame.SetPixel(x, y, new Pixel(255, 32, 255));
                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();
 }
Example #10
0
        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();
                }
            }
        }