private void Button_Click_2(object sender, RoutedEventArgs e) { //BitmapSource currentScreen = Win8Parser.copyScreen(); //imgPart.Source = currentScreen; //PixelColor[,] testPixels = BitmapSourceHelper.GetPixels(testBMP); //new BlockParser().Parse(0, 0, testPixels); //PixelColor testColor = testPixels[Int32.Parse(txtX.Text), Int32.Parse(txtY.Text)]; //txtPixel.Text = testColor.ToString(); //btnPart.Background = new SolidColorBrush(Color.FromArgb(testColor.Alpha, (byte)testColor.Red, (byte)testColor.Green, (byte)testColor.Blue)); int x = Int32.Parse(txtCoordX.Text); int y = Int32.Parse(txtCoordY.Text); int captureWidth = 1920; int captureHeight = 1200; Surface surface = new DxScreenCapture().CaptureScreen(); DataRectangle dr = surface.LockRectangle(new System.Drawing.Rectangle(0, 0, captureWidth, captureHeight), LockFlags.None); DataStream gs = dr.Data; WriteableBitmap wb = new WriteableBitmap(54, 54, 96, 96, PixelFormats.Bgra32, null); int bytesPerPixel = (wb.Format.BitsPerPixel + 7) / 8; int stride = wb.PixelWidth * bytesPerPixel; byte[] buffer = new byte[54 * 4 * 54]; for (int i = 0; i < 54; i++) { gs.Position = (i + y) * captureWidth * 4 + x * 4; gs.Read(buffer, 54 * 4 * i, 54 * 4); } wb.WritePixels(new Int32Rect(0, 0, 54, 54), buffer, 54 * 4, 0); imgPart.Source = wb; }
public ScreenDev() { // 1024px * 768px * 3Bytes _screen = new byte[2359296]; _sc = new DxScreenCapture(); _scGDI = new Screenshot(); _screenServer = new UDPServer(0); }
public void Run() { log.Info("Initializing DirectX screen capture"); sc = new DxScreenCapture(); fullScreenMonitor = new FullScreenMonitor(); fullScreenMonitor.Changed += HandleFullScreenApplicationChanged; fullScreenMonitor.Start(); /* * var format = SharpDX.Direct3D9.Format.A8B8G8R8; * * SharpDX.Direct3D9.PresentParameters present_paramsS = new SharpDX.Direct3D9.PresentParameters(); * * present_paramsS.Windowed = true; * present_paramsS.SwapEffect = SharpDX.Direct3D9.SwapEffect.Discard; * * SharpDX.Direct3D9.Device dS = new SharpDX.Direct3D9.Device(new SharpDX.Direct3D9.Direct3D(), * 0, * SharpDX.Direct3D9.DeviceType.NullReference, * IntPtr.Zero, * SharpDX.Direct3D9.CreateFlags.SoftwareVertexProcessing, * present_paramsS); */ ambilightWorker = new BackgroundWorker(); ambilightWorker.DoWork += AnalyzeBackgroundColor; ambilightWorker.WorkerSupportsCancellation = true; log.Info("Starting background worker"); ambilightWorker.RunWorkerAsync(); while (ambilightWorker.IsBusy) { System.Windows.Forms.Application.DoEvents(); Thread.Sleep(10); } DetachFromHookedProcess(); log.Info("Stopping active window monitor"); fullScreenMonitor.Stop(); log.Info("Service stopped"); }
public Logic() { { setupScreenZones(); setupProgramSettings(); setupHUE(); setupLights(); DxScreenCapture = new DxScreenCapture(); //var timer = new System.Timers.Timer(200); //timer.Enabled = true; //timer.Elapsed += timer_Elapsed; //while (true) //{ // timer_Elapsed(); // Thread.Sleep(150); //} } }