[英]How to check if image in gallery was taken from camera or screenshot?
I am uploading an image from my gallery and setting it as a bitmap.我正在从我的画廊上传一张图片并将其设置为 bitmap。 In my scenario, whenever I upload a screenshot from gallery,在我的场景中,每当我从图库上传截图时,
The bitmap looks clean and fit bitmap 看起来干净又合身
But, when I upload a picture which was taken from back/front camera, the bitmap is rotated 90 degrees.但是,当我上传从后置/前置摄像头拍摄的照片时,bitmap 旋转了 90 度。
How do I detect if an gallery image was taken by camera or screenshot?如何检测图库图像是由相机还是屏幕截图拍摄的?
Check if the dimensions of the image fits with the dimensions of the screen. 检查图像尺寸是否适合屏幕尺寸。 Considering bitmap
is the image you want to check: 考虑bitmap
是您要检查的图像:
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
if(bitmap.getWidth() == size.x && bitmap.getHeight() == size.y){
// Then is a screenshot
}else{
// Then is not a screenshot
}
This isn't a great solution, but it's something ¯\_(ツ)_/¯这不是一个很好的解决方案,但它是¯\_(ツ)_/¯
filename.contains("screenshot", ignoreCase = true)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.