I am implementing a feature to capture the screen in landscape mode. However, when I capture after rotating clockwise, a black bar appears on the right side, and when I capture after rotating counterclockwise, a black bar appears on the left side. How can I resolve this issue? I am unable to determine the cause.
below my code:
Image.Plane[] planes = image.getPlanes();
ByteBuffer buffer = planes[0].getBuffer();
int pixelStride = planes[0].getPixelStride();
int rowStride = planes[0].getRowStride();
int rowPadding = rowStride - pixelStride * mWidth;
// create bitmap
//mWidth and mHeight is device's size
bitmap = Bitmap.createBitmap(mWidth + rowPadding / pixelStride, mHeight - getStatusBarHeight() - getNavigationBarHeight(CaptureService.this), Bitmap.Config.ARGB_8888);
int bytesPerPixel = ImageFormat.getBitsPerPixel(ImageFormat.YUV_420_888) / 8;
buffer.position((getStatusBarHeight() * rowStride) / bytesPerPixel);
bitmap.copyPixelsFromBuffer(buffer);
// write bitmap to a file
fos = new FileOutputStream(mStoreDir + "screen.jpg");
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos);
and example screenshot below: