如何在不损失分辨率的情况下放大和缩小位图?
我正在尝试实现捏缩放并且它正在工作,但是当我缩小然后再次放大时,图像(位图)的分辨率会降低。 我知道这只是我的代码的正常行为,我想知道如何以正确的方式做到这一点。
这是相关代码:
Matrix matrix = new Matrix() ;
float scale = newDist / oldDist;
matrix.postScale(scale, scale, mid.x, mid.y);
int width = mutable.getWidth() ;
int height = mutable.getHeight() ;
mutable = Bitmap.createBitmap(mutable, 0, 0, width, height, matrix, false);
I am trying to implement pinch zoom and it is working but when i zoom out and then zoom in again the resolution of the image(bitmap) decreases.
I am aware that this is just normal behavior of my code and i want to know how to do this with right way .
here is the relevant code :
Matrix matrix = new Matrix() ;
float scale = newDist / oldDist;
matrix.postScale(scale, scale, mid.x, mid.y);
int width = mutable.getWidth() ;
int height = mutable.getHeight() ;
mutable = Bitmap.createBitmap(mutable, 0, 0, width, height, matrix, false);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
保持原始位图不变。每次调整大小时,您都会在原始版本的克隆上工作。
Keep the original bitmap unchanged. Everytime you resize you work on a clone of that original.
这里有一个教程:
http://blogs.sonyericsson.com/wp/2010/05/18/android-one-finger-zoom-tutorial-part-1/
There is a tutorial here:
http://blogs.sonyericsson.com/wp/2010/05/18/android-one-finger-zoom-tutorial-part-1/