简体   繁体   English

旋转画布后,位图失去质量

[英]Bitmap loses its quality after rotating canvas

I have a lot of draw operations in my custom view(compass). 我的自定义视图(指南针)中有很多绘制操作。 I decided to optimize it by drawing whole compass on a bitmap in onSizeChanged() method, instead of just drawing it directly every time onDraw() triggers. 我决定通过在onSizeChanged()方法中onSizeChanged()图上绘制整个指南针来优化它,而不是每次onDraw()触发器都直接绘制它。

Here is a part of onDraw() method: 这是onDraw()方法的一部分:

canvas.rotate(-heading, x, y);
canvas.drawBitmap(compassBitmap, 0f, compassBitmapY, compassBitmapPaint);

My problem is what happens after rotation. 我的问题是旋转后会发生什么。 Bitmap loses its quality. 位图会失去质量。 Setting ANTI_ALIAS_FLAG does not help at all. 设置ANTI_ALIAS_FLAG完全没有帮助。 Is there any way to deal with this problem or should i get back to the "heavier" implementation? 有什么办法可以解决这个问题,还是我应该回到“较重的”实现?

it's impossible to rotate image without loosing it's quality, it's limited by resolution. 旋转图像而不损失其质量是不可能的,它受分辨率的限制。

Each pixel position need to be recalculed, if new destination is not (int, int) pixels needs to be mixed to be closest from the original image. 如果新目的地不是(int,int),则需要重新计算每个像素位置(像素,整数),以使其与原始图像最接近。

在此处输入图片说明在此处输入图片说明

http://homepages.inf.ed.ac.uk/rbf/HIPR2/rotate.htm http://homepages.inf.ed.ac.uk/rbf/HIPR2/rotate.htm

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM