简体   繁体   English

如何检查图库中的图像是从相机还是屏幕截图中拍摄的?

[英]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.

相关问题 如何在图库中的imageView上设置图像以及在Android中由相机拍摄的图像? - How to set an image on imageView from the gallery and image taken by camera in Android? 如何旋转从相机或画廊拍摄的图像? - How rotate image taken from camera or gallery.? 从相机拍摄后将图像保存到图库 - save image to the gallery after taken from the camera 如何确定图库中的图像是从相机拍摄的肖像还是风景 - How to find out if the image from the gallery was taken in portrait or landscape from camera ImageView不显示从手机摄像头或照片库拍摄的图像 - ImageView does not display image taken from phone camera or photo gallery Android通过使用文件系统保存从相机或图库拍摄的图像 - Android save taken image from camera or gallery by using file system 在上传之前,请调整从图库或照相机拍摄的图像的大小 - Resize image taken from gallery or camera, before being uploaded 如何动态更新从Android中的本机相机拍摄的照片库? - How to dynamically update an image gallery upon the photos taken from the native camera in android? 如何扫描相机意图拍摄的图像以更新Android中的图库 - How to scan image taken by camera intent to update gallery in android 无法从图库中获取相机拍摄的图像 - Cannot fetch images taken by camera from Gallery
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM