简体   繁体   English

根植Android设备的屏幕截图反转

[英]Inverted Screenshot rooted Android device

I have the following code that takes a screenshot of my rooted android device. 我有以下代码,其中包含我已扎根的android设备的屏幕截图。

Process sh = Runtime.getRuntime().exec("su", null,null);
OutputStream os = sh.getOutputStream();
os.write(("/system/bin/screencap -p " + "/sdcard/img.png").getBytes("ASCII"));
os.flush();

My device is inserted into a case and is technically positioned in an inverted fashion. 我的设备已插入外壳,并且在技术上以相反的方式放置。 But now when I take a screenshot it appears upside down. 但是现在,当我拍摄屏幕快照时,它看起来是颠倒的。 Is there a way to take the screenshot and rotate it before it is sent to the sdcard? 有没有办法在将截图发送到sdcard之前对其进行旋转?

As you can see yourself from the source of the screencap tool at 如您从屏幕截图工具的来源看到的那样

https://android.googlesource.com/platform/frameworks/base/+/master/cmds/screencap/screencap.cpp https://android.googlesource.com/platform/frameworks/base/+/master/cmds/screencap/screencap.cpp

there is no built-in option to do so. 没有内置选项可以这样做。

However, with a rooted device you have the option of modifying that tool to re-order the output data. 但是,对于有根设备,您可以选择修改该工具以对输出数据重新排序。

You also have the option of capturing the output in your java program, and re-ordering it there before writing it to a file. 您还可以选择捕获Java程序中的输出,然后在将其写入文件之前在其中重新排序。 Or of making your own native program to pipe through. 或制作自己的本机程序来进行传递。

Finally, you could script some common tool such as imagemagick to do so on whatever system you are using to examine the results. 最后,您可以使用一些常用工具(例如imagemagick)编写脚本,以在用于检查结果的任何系统上执行此操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM