【发布时间】:2016-05-09 21:38:32
【问题描述】:
我认为它应该是重复的,但我没有得到这个问题的任何解决方案。我的问题是:
我正在开发一个应用程序,它具有诸如具有纵横比的裁剪和具有旋转和拉直功能的裁剪等功能。为此,我正在使用this 库。具有裁剪、旋转和拉直功能,但我的问题是在调用裁剪功能以拉直图像后,结果质量不佳。我该如何克服这个问题?
这是我用于裁剪的代码:
private Bitmap getCurrentDisplayedImage() {
Bitmap result = Bitmap.createBitmap(mImageView.getWidth(), mImageView.getHeight(), Bitmap.Config.RGB_8888);
Canvas c = new Canvas(result);
mImageView.draw(c);
return result;}
// Get the scale factor between the actual Bitmap dimensions and the
// displayed dimensions for width.
float actualImageWidth = mCurrentDisplayedBitmap.getWidth();
float displayedImageWidth = displayedImageRect.width();
float scaleFactorWidth = actualImageWidth / displayedImageWidth;
// Get the scale factor between the actual Bitmap dimensions and the
// displayed dimensions for height.
float actualImageHeight = mCurrentDisplayedBitmap.getHeight();
float displayedImageHeight = displayedImageRect.height();
float scaleFactorHeight = actualImageHeight / displayedImageHeight;
// Get crop window position relative to the displayed image.
float cropWindowX = Edge.LEFT.getCoordinate() - displayedImageRect.left;
float cropWindowY = Edge.TOP.getCoordinate() - displayedImageRect.top;
float cropWindowWidth = Edge.getWidth();
float cropWindowHeight = Edge.getHeight();
// Scale the crop window position to the actual size of the Bitmap.
float actualCropX = cropWindowX * scaleFactorWidth;
float actualCropY = cropWindowY * scaleFactorHeight;
float actualCropWidth = cropWindowWidth * scaleFactorWidth;
float actualCropHeight = cropWindowHeight * scaleFactorHeight;
// Crop the subset from the original Bitmap.
Bitmap croppedBitmap = Bitmap.createBitmap(mCurrentDisplayedBitmap, (int) actualCropX, (int) actualCropY, (int) actualCropWidth, (int) actualCropHeight);
return croppedBitmap;}
我用谷歌搜索了很多方法,但没有找到更好的解决方案。
如果有人有想法,请帮助我。
感谢提前。
【问题讨论】:
标签: android bitmap rotation crop