Example #1
0
        public System.Drawing.Bitmap CaptureScreenshot(bool isRotate = false)
        {
            var watch = new Stopwatch();

            watch.Start();

            var bytes = AdbApi.CaptureScreenshot(AdbStream);

            //System.IO.File.WriteAllBytes(@"p:\temp\q1.png", bytes);

            var captureTime = watch.Elapsed;

            watch.Reset();
            //Log.Information("Capture {captureTime}", captureTime);

            watch.Start();

            var bitmap = LoadRawBitmap(bytes);

            //var bitmap = (System.Drawing.Bitmap)System.Drawing.Bitmap.FromStream(new System.IO.MemoryStream(bytes));
            if (isRotate)
            {
                bitmap.RotateFlip(System.Drawing.RotateFlipType.Rotate270FlipNone);
            }

            var rotateTime = watch.Elapsed;

            Log.Information("Capture {captureTime}, {rotateTime}", captureTime, rotateTime);

            return(bitmap);
        }
Example #2
0
        public AdbClient(string device, int?adbPort = null)
        {
            this.Device  = device;
            this.AdbPort = adbPort ?? AdbPort_Default;

            this.TcpClient = new TcpClient("127.0.0.1", AdbPort);
            this.AdbStream = this.TcpClient.GetStream();

            AdbApi.RunCommand(AdbStream, $"host:transport:{Device}");
        }
Example #3
0
 public void Back()
 {
     AdbApi.Back(AdbStream);
 }
Example #4
0
 public void Tap(int x, int y)
 {
     AdbApi.Tap(AdbStream, x, y);
 }
Example #5
0
 public string Shell(string command)
 {
     return(AdbApi.RunShellCommand(AdbStream, command));
 }