Closed RazorPT closed 9 years ago
I have tested the app on emulator and on a Nexus 7 with 5.0.2 and worked fine. Which Android version is your Nexus 5 running? Also, I recently changed ImageFormat from ImageFormat.JPEG to ImageFormat.RGBA_8888, try the other way round and let me know if it had any effect.
Have a look also at http://stackoverflow.com/questions/26673127/android-imagereader-acquirelatestimage-returns-invalid-jpg/28843224#28843224 especially an answer provided by binW.
My nexus 5 is running 5.0.1 i tested changing PixelFormat.RGBA_8888 to .JPEG but it started giving me this error on logcat "[unnamed-31494-2] dequeueBuffer: can't dequeue multiple buffers without setting the buffer count and didn´t produce any screenshots", reverting to original code to PixelFormat.RGBA_8888 starts producing screenshots with the old problem.
It is really weird problem, it will take a look into that stackoverflow answer
Okay i just tested the code from the stackoverflow answer and replaced your code:
Image.Plane[] planes = image.getPlanes(); Buffer imageBuffer = planes[0].getBuffer().rewind();
// create bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); bitmap.copyPixelsFromBuffer(imageBuffer);
With the code from the stackoverflow answer and problem solved! At least for me :) It seems the problem is that you can´t generate a bitmap with the same size as the virtual display since the returned images are bigger so you have to take into account the PixelStride and RowStride. You can read more on the author´s blog: http://binwaheed.blogspot.com
I can´t seem to reproduce your problem with "The producer output buffer format 0x1 doesn't match the ImageReader's configured buffer format 0x4"
By the way any idea to how to screen capture as a video? (Screen record)
I got the Exception on my Nexus 7 so perhaps I missed some step along the way. Can you send me the exact diff so as to have a look?
Regarding video I don't see how you can do it with this API, in case you find any solution though let us know :)
Had time today so made more tests on this.
My observations, based on a Nexus 7 running Android 5.0.2:
I will update the code to reflect the change.
Unable to get PixelFormat enum in xamarin android? any idea?
Funny thing the app works correctly on the emulator but not on a Nexus 5 device: