private void SSerialConnect_Click(object sender, RoutedEventArgs e) { switch (SSColorModeList.SelectedIndex) { case 0: SerialManager.ColorMode = SerialManager.CMode.BPP24RGB; break; case 1: SerialManager.ColorMode = SerialManager.CMode.BPP16RGB; break; case 2: SerialManager.ColorMode = SerialManager.CMode.BPP8RGB; break; case 3: SerialManager.ColorMode = SerialManager.CMode.BPP8Gray; break; case 4: SerialManager.ColorMode = SerialManager.CMode.BPP1Mono; break; } int[] matrixDef = null; matrixDef = SerialManager.Connect(SSerialPortList.SelectedValue.ToString(), int.Parse(SBaudRate.Text)); if (matrixDef != null) { MatrixFrame.SetDimensions(matrixDef[0], matrixDef[1]); // ((MainWindow)Application.Current.MainWindow).SetMatrixDimensions(matrixDef[0], matrixDef[1]); Close(); } else { MessageBox.Show("Cannot establish connection on: " + SSerialPortList.SelectedValue.ToString()); } }
void StartSerialSyncCapture() { _fpsStopWatch = Stopwatch.StartNew(); SerialManager.SerialAcknowledged += OnSerialAcknowledged; MatrixFrame.InjestGDIBitmap(ScreenRecorder.ScreenToBitmap(), ScreenRecorder.InterpMode); // Dispatcher.Invoke(() => { FrameToPreview(); }); SerialManager.PushFrame(); }
void FFTCallback(float[] fftData) //data received { Dispatcher.Invoke(() => { MatrixFrame.FFTToFrame(fftData); //FrameToPreview(); SerialManager.PushFrame(); }); }
//Matrix Frame Functions //=========================================================================================== private void FrameToPreview() { MatrixBitmap.Lock(); IntPtr pixelAddress = MatrixBitmap.BackBuffer; Marshal.Copy(MatrixFrame.FrameToInt32(), 0, pixelAddress, (MatrixFrame.Width * MatrixFrame.Height)); MatrixBitmap.AddDirtyRect(new Int32Rect(0, 0, MatrixFrame.Width, MatrixFrame.Height)); MatrixBitmap.Unlock(); }
void OnSerialAcknowledged() { if (SyncSerial == true) { MatrixFrame.InjestGDIBitmap(ScreenRecorder.ScreenToBitmap(), ScreenRecorder.InterpMode); // Dispatcher.Invoke(() => { FrameToPreview(); }); SerialManager.PushFrame(); LocalFPS = SerialFPS = _fpsStopWatch.ElapsedMilliseconds - _localPreviousMillis; _localPreviousMillis = _fpsStopWatch.ElapsedMilliseconds; } }
public MainWindow() { DataContext = this; InitializeComponent(); MatrixFrame.DimensionsChanged += OnMatrixDimensionsChanged; MatrixFrame.FrameChanged += OnFrameChanged; MatrixFrame.SetDimensions(MatrixFrame.Width, MatrixFrame.Height); InitializeScreenCaptureUI(); InitializeAudioCaptureUI(); MatrixFrame.BitmapToFrame(Properties.Resources.Icon16, System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor); //FrameToPreview(); }
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(); }
private void WriteFile(string path) { //System.Windows.Forms.MessageBox.Show(path); string[] formattedData = new string[MatrixFrame.Height]; /* * for (int i = 0; i < MatrixFrame.Height; i++) * { * for(int e = 0; e < MatrixFrame.Width; e++) * { * formattedData[i] += "0x" + Convert.ToString(MatrixFrame.Frame[i * MatrixFrame.Width + e].R, 16) + ","; * formattedData[i] += "0x" + Convert.ToString(MatrixFrame.Frame[i * MatrixFrame.Width + e].G, 16) + ","; * formattedData[i] += "0x" + Convert.ToString(MatrixFrame.Frame[i * MatrixFrame.Width + e].B, 16) + ", "; * } * formattedData[i] += "\n"; * } * * for (int i = 0; i < MatrixFrame.Height; i++) * { * for (int e = 0; e < MatrixFrame.Width; e++) * { * formattedData[i] += "B" + Convert.ToString(MatrixFrame.Frame[i * MatrixFrame.Width + e].R, 2) + ","; * formattedData[i] += "B" + Convert.ToString(MatrixFrame.Frame[i * MatrixFrame.Width + e].G, 2) + ","; * formattedData[i] += "B" + Convert.ToString(MatrixFrame.Frame[i * MatrixFrame.Width + e].B, 2) + ", "; * } * formattedData[i] += "\n"; * } */ string[] d = { BitConverter.ToString(MatrixFrame.GetOrderedSerialFrame()) }; for (int i = 0; i < MatrixFrame.Height; i++) { for (int e = 0; e < MatrixFrame.Width; e++) { formattedData[i] += "0x" + MatrixFrame.Frame[i * MatrixFrame.Width + e].R.ToString("X2") + ","; formattedData[i] += "0x" + MatrixFrame.Frame[i * MatrixFrame.Width + e].G.ToString("X2") + ","; formattedData[i] += "0x" + MatrixFrame.Frame[i * MatrixFrame.Width + e].B.ToString("X2") + ","; } formattedData[i] += "\n"; } System.IO.File.WriteAllLines(path, formattedData); }
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(); } }
void DrawPixel() { if (Mouse.LeftButton == MouseButtonState.Pressed || Mouse.RightButton == 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; if (Mouse.LeftButton == MouseButtonState.Pressed) { MatrixFrame.SetPixel(x, y, new Pixel(255, 255, 255)); } else { MatrixFrame.SetPixel(x, y, new Pixel(0, 0, 0)); } } }
void FFTCallback(float[] fftData) //data received { Dispatcher.Invoke(() => { // MatrixFrame.FFTToFrame(fftData); MatrixFrame.FillFrame(new Pixel(0, 0, 0)); float[] downSampledData = ResizeSampleArray(fftData, MatrixFrame.Width); for (int i = 0; i < MatrixFrame.Width; i++) { if (SelectedDisplayMode == 0) { MatrixFrame.DrawColumnMirrored(i, (int)(downSampledData[i] * MatrixFrame.Height), _bottomColorPixel, _topColorPixel); } if (SelectedDisplayMode == 1) { MatrixFrame.DrawColumn(i, (int)(downSampledData[i] * MatrixFrame.Height), _bottomColorPixel, _topColorPixel); } } MatrixFrame.Refresh(); }); }
private void PixelOrder_NewLine_Snake_Click(object sender, RoutedEventArgs e) { MatrixFrame.newLine = PixelOrder.NewLine.SN; MatrixFrame.Refresh(); }
private void PixelOrder_StartCorner_BottomRight_Click(object sender, RoutedEventArgs e) { MatrixFrame.startCorner = PixelOrder.StartCorner.BR; MatrixFrame.Refresh(); }
private void PixelOrder_StartCorner_TopLeft_Click(object sender, RoutedEventArgs e) { MatrixFrame.startCorner = PixelOrder.StartCorner.TL; MatrixFrame.Refresh(); }
private void PixelOrder_Orientation_Vertical_Click(object sender, RoutedEventArgs e) { MatrixFrame.orientation = PixelOrder.Orientation.VT; MatrixFrame.Refresh(); }
private void MenuItem_Serial_ColorMode_BPP1Mono_Click(object sender, RoutedEventArgs e) { SerialManager.ColorMode = SerialManager.CMode.BPP1Mono; MatrixFrame.Refresh(); OnColorModeChanged(); }