From 0137fb8937e69ed41cff3bf8cb0c1fea43daa3b5 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Wed, 20 Mar 2013 15:38:07 -0700 Subject: make sure screencap's data stream matches what adb expects adb assumes the stride is always equal to the width, so we make sure it's actually the case (screenshot don't always have this guarantee). Change-Id: I643b909f6542b7493a611afc6e3c86955b984352 --- cmds/screencap/screencap.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'cmds/screencap') diff --git a/cmds/screencap/screencap.cpp b/cmds/screencap/screencap.cpp index d196392..e1270af 100644 --- a/cmds/screencap/screencap.cpp +++ b/cmds/screencap/screencap.cpp @@ -28,6 +28,8 @@ #include #include +#include + #include #include #include @@ -138,7 +140,7 @@ int main(int argc, char** argv) ssize_t mapsize = -1; void const* base = 0; - uint32_t w, h, f; + uint32_t w, s, h, f; size_t size = 0; ScreenshotClient screenshot; @@ -147,6 +149,7 @@ int main(int argc, char** argv) base = screenshot.getPixels(); w = screenshot.getWidth(); h = screenshot.getHeight(); + s = screenshot.getStride(); f = screenshot.getFormat(); size = screenshot.getSize(); } else { @@ -160,6 +163,7 @@ int main(int argc, char** argv) size_t offset = (vinfo.xoffset + vinfo.yoffset*vinfo.xres) * bytespp; w = vinfo.xres; h = vinfo.yres; + s = vinfo.xres; size = w*h*bytespp; mapsize = offset + size; mapbase = mmap(0, mapsize, PROT_READ, MAP_PRIVATE, fb, 0); @@ -187,7 +191,11 @@ int main(int argc, char** argv) write(fd, &w, 4); write(fd, &h, 4); write(fd, &f, 4); - write(fd, base, size); + size_t Bpp = bytesPerPixel(f); + for (size_t y=0 ; y