MediaProjectionDemo icon indicating copy to clipboard operation
MediaProjectionDemo copied to clipboard

Bug: black margins on left and right

Open AndroidDeveloperLB opened this issue 7 years ago • 4 comments

Just noticed that the sample produces files with black left&right margins:

myscreen_5

Why does it occur? What should be done to fix it? Tested on Nexus 5x with Android 7.1.2

AndroidDeveloperLB avatar Apr 29 '17 19:04 AndroidDeveloperLB

Please check http://stackoverflow.com/questions/27581750/android-capture-screen-to-surface-of-imagereader for a full explanation.

If you try adding the solution, this is the patch:

diff.txt

I am not going to apply it in the demo as it is a performance killer (check the two loops it performs) but for a use case you mentioned in another thread (capturing a single image, I think you added a new task for that) should be fine.

mtsahakis avatar May 02 '17 17:05 mtsahakis

Basically Image.Plane buffers have some padding for each row that you either accept it in the final product and add it to the bitmap (black margins) or you try to remove it (but removal is slow).

mtsahakis avatar May 02 '17 17:05 mtsahakis

But it adds this padding not just in the end, but also in the beginning. The link you've provided says it's only at the end, and it's also the solution there: https://commonsware.com/Android/previews/screenshots-and-screen-recordings

AndroidDeveloperLB avatar May 02 '17 18:05 AndroidDeveloperLB

Anyway, I've put a StackOverflow question about this:

http://stackoverflow.com/q/43705756/878126

AndroidDeveloperLB avatar May 02 '17 20:05 AndroidDeveloperLB