summaryrefslogtreecommitdiffstats
path: root/cmds/screencap/screencap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cmds/screencap/screencap.cpp')
-rw-r--r--cmds/screencap/screencap.cpp12
1 files changed, 10 insertions, 2 deletions
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 <gui/SurfaceComposerClient.h>
#include <gui/ISurfaceComposer.h>
+#include <ui/PixelFormat.h>
+
#include <SkImageEncoder.h>
#include <SkBitmap.h>
#include <SkData.h>
@@ -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<h ; y++) {
+ write(fd, base, w*Bpp);
+ base = (void *)((char *)base + s*Bpp);
+ }
}
}
close(fd);