Java 如何理解位图照片是垂直的还是水平的?
我没有在google和stackoverflow上找到我真正需要的东西, 我想知道我刚从相机上拍摄的照片是垂直的还是水平的, 代码: 当我在手机上拍摄照片时,imageHeight和ImageWidt总是相同的,我的意思是如果我拍摄照片垂直或水平,它总是960x1280,我想水平照片大小是宽度:960高度:1280,垂直是宽度:1280高度:960Java 如何理解位图照片是垂直的还是水平的?,java,android,bitmap,android-bitmap,Java,Android,Bitmap,Android Bitmap,我没有在google和stackoverflow上找到我真正需要的东西, 我想知道我刚从相机上拍摄的照片是垂直的还是水平的, 代码: 当我在手机上拍摄照片时,imageHeight和ImageWidt总是相同的,我的意思是如果我拍摄照片垂直或水平,它总是960x1280,我想水平照片大小是宽度:960高度:1280,垂直是宽度:1280高度:960 谢谢我想你可以做一个简单的高度和宽度测试,比如: if(imageHeight > imageWidth){ //Image is h
谢谢我想你可以做一个简单的高度和宽度测试,比如:
if(imageHeight > imageWidth){
//Image is horizontal (according to your comments, horizontal photos are usually wider than the hight)
}
elseif(imageHeight > imageWidth){
//Image is horizontal (again, according to your comments)
}
我想你可以做一个简单的高度和宽度测试,比如:
if(imageHeight > imageWidth){
//Image is horizontal (according to your comments, horizontal photos are usually wider than the hight)
}
elseif(imageHeight > imageWidth){
//Image is horizontal (again, according to your comments)
}
使用以获取方向,如下所示:
File imageFile = new File(imagePath);
ExifInterface exif = new ExifInterface(imageFile.getAbsolutePath());
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
boolean isVertical = true ;
switch (orientation) {
case ExifInterface.ORIENTATION_ROTATE_270:
isVertical = false ;
break;
case ExifInterface.ORIENTATION_ROTATE_90:
isVertical =false ;
break;
}
依此类推,以获取ExiFinInterface文档中的常量所需的所有内容
然后,您可以尝试使用API执行以下操作:
请给我一些反馈
希望有帮助 使用获取方向,如下所示:
File imageFile = new File(imagePath);
ExifInterface exif = new ExifInterface(imageFile.getAbsolutePath());
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
boolean isVertical = true ;
switch (orientation) {
case ExifInterface.ORIENTATION_ROTATE_270:
isVertical = false ;
break;
case ExifInterface.ORIENTATION_ROTATE_90:
isVertical =false ;
break;
}
依此类推,以获取ExiFinInterface文档中的常量所需的所有内容
然后,您可以尝试使用API执行以下操作:
请给我一些反馈
希望有帮助 然后,您必须从从相机获得的位图创建另一个位图,然后您必须从从相机获得的位图创建另一个位图。图像高度和图像宽度始终是相同的值,我的意思是它们是1280x960。我的意思是,如果我捕获图像宽度=1280,重量是960,则图像高度和图像宽度始终是相同的相同的值,我的意思是它们是1280x960,我的意思是如果我拍摄图像宽度=1280,重量总是960,问题是我如何理解垂直或水平方向?因为我拍摄的图像是垂直或水平放置在手机上,位图显示的值总是相同的,所以问题是我如何理解垂直或水平?因为我将图像垂直或水平放置在手机上,位图显示的值总是相同的,