Android ImageView setRotation具有锯齿边或锯齿边
您好,目前我正在尝试显示一个图像,在我捕获它并将图像旋转到正确的方向(相机问题)后,它在imageview上旋转了大约5度。现在的问题是,在使用Android ImageView setRotation具有锯齿边或锯齿边,android,Android,您好,目前我正在尝试显示一个图像,在我捕获它并将图像旋转到正确的方向(相机问题)后,它在imageview上旋转了大约5度。现在的问题是,在使用imageview将图像设置在旋转5度的imageview上。setRotation(5)imageview本身会出现锯齿。我很确定imageview是一个别名,因为我的图像有一个5dp的填充,在侧面有一个白色边框,但是如果我错了,请纠正我 到目前为止,我尝试的解决方案是,示例解决方案适用于自定义视图上已设置的图像,而我不习惯根据需要配置或进一步自定义自
imageview将图像设置在旋转5度的imageview上。setRotation(5)
imageview本身会出现锯齿。我很确定imageview是一个别名,因为我的图像有一个5dp的填充,在侧面有一个白色边框,但是如果我错了,请纠正我
到目前为止,我尝试的解决方案是,示例解决方案适用于自定义视图上已设置的图像,而我不习惯根据需要配置或进一步自定义自定义视图。虽然他的问题和我的差不多
我还尝试了即时应用抗锯齿的方法,但效果并不理想
到目前为止,我的代码如下:
imageview = (ImageView) findViewById(R.id.img_preview);
imageview.setRotation(5);
Bundle extras = getIntent().getExtras();
if (extras != null) {
String img_path = extras.getString("img_path");
File image_file = new File(img_path);
try {
Bitmap captured_image = applyOrientation(BitmapFactory.decodeFile(img_path),resolveBitmapOrientation(image_file));
imageview.setImageBitmap(captured_image);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
这是我旋转图像的代码,也许有人可以帮我从这里修复它,就是这样:
private int resolveBitmapOrientation(File bitmapFile) throws IOException {
ExifInterface exif = null;
exif = new ExifInterface(bitmapFile.getAbsolutePath());
return exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
}
private Bitmap applyOrientation(Bitmap bitmap, int orientation) {
int rotate = 0;
switch (orientation) {
case ExifInterface.ORIENTATION_ROTATE_270:
rotate = 270;
break;
case ExifInterface.ORIENTATION_ROTATE_180:
rotate = 180;
break;
case ExifInterface.ORIENTATION_ROTATE_90:
rotate = 90;
break;
default:
return bitmap;
}
int w = bitmap.getWidth();
int h = bitmap.getHeight();
Matrix mtx = new Matrix();
mtx.postRotate(rotate);
return Bitmap.createBitmap(bitmap, 0, 0, w, h, mtx, true);
}
这里可能是dup:先生,我已经看过那篇文章了,虽然他的实现方式有点不同,但它与我的问题有关。