private void setOffset(DataStream gs) { PixelColor[,] test = BitmapSourceHelper.GetPixels(new BitmapImage(new Uri(@"pack://application:,,,/MinesweeperSolver;component/Images/test.png"))); int testWidth = 5; int testHeight = 5; byte[] buffer = new byte[testWidth * 4 * testHeight]; PixelColor[,] pixels = new PixelColor[testWidth, testHeight]; for (int x = 0; x < screenWidth - 5; x += 5) { for (int y = 0; y < screenHeight - 5; y += 5) { for (int line = 0; line < testHeight; line++) { gs.Position = (line + y) * screenWidth * 4 + x * 4; gs.Read(buffer, testWidth * 4 * line, testWidth * 4); } for (int a = 0; a < testWidth; a++) { for (int b = 0; b < testHeight; b++) { int offset = b * testWidth * 4 + (a * 4); pixels[b, a].Red = buffer[offset + 2]; pixels[b, a].Green = buffer[offset + 1]; pixels[b, a].Blue = buffer[offset + 0]; } } if (BlockParser.CompareImages(pixels, test)) { int finalX; int finalY; byte[] pixel = new byte[4]; for (finalX = x; finalX > 0; finalX--) { gs.Position = y * screenWidth * 4 + finalX * 4; gs.Read(pixel, 0, 4); if (compareInt(pixel[0], 58, 9) && compareInt(pixel[1], 52, 9) && compareInt(pixel[2], 47, 9)) { break; } } for (finalY = y; finalY > 0; finalY--) { gs.Position = finalY * screenWidth * 4 + x * 4; gs.Read(pixel, 0, 4); if (compareInt(pixel[0], 58, 9) && compareInt(pixel[1], 52, 9) && compareInt(pixel[2], 47, 9)) { break; } } xoffset = finalX - 3; yoffset = finalY - 1; return; } } } }
private int yoffset = 168; //168 #endregion Fields #region Constructors public Win8Parser() { this.blockParser = new BlockParser(); dx = new DxScreenCapture(); }
public Win8Parser() { this.blockParser = new BlockParser(); dx = new DxScreenCapture(); }