private int yoffset = 168; //168 #endregion Fields #region Constructors public Win8Parser() { this.blockParser = new BlockParser(); dx = new DxScreenCapture(); }
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 Win8Parser() { this.blockParser = new BlockParser(); dx = new DxScreenCapture(); }