如何在不损失分辨率的情况下放大和缩小位图?

发布于 2024-09-29 19:23:32 字数 384 浏览 1 评论 0原文

我正在尝试实现捏缩放并且它正在工作,但是当我缩小然后再次放大时,图像(位图)的分辨率会降低。 我知道这只是我的代码的正常行为,我想知道如何以正确的方式做到这一点。

这是相关代码:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

国粹 2024-10-06 19:23:32

保持原始位图不变。每次调整大小时,您都会在原始版本的克隆上工作。

Keep the original bitmap unchanged. Everytime you resize you work on a clone of that original.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文