/// <include file='IAdbClient.xml' path='/IAdbClient/GetFrameBuffer/*'/> public async Task <Image> GetFrameBuffer(DeviceData device, CancellationToken cancellationToken) { using (IAdbSocket socket = Factories.AdbSocketFactory(this.EndPoint)) { // Select the target device this.SetDevice(socket, device); // Send the framebuffer command socket.SendAdbRequest("framebuffer:"); socket.ReadAdbResponse(); // The result first is a FramebufferHeader object, var size = Marshal.SizeOf(typeof(FramebufferHeader)); var headerData = new byte[size]; await socket.ReadAsync(headerData, cancellationToken).ConfigureAwait(false); var header = FramebufferHeader.Read(headerData); // followed by the actual framebuffer content var imageData = new byte[header.Size]; socket.Read(imageData); // Convert the framebuffer to an image, and return that. return(header.ToImage(imageData)); } }