如何画和规模在Android中使用双三次插值在画布上的位图? [英] How to draw and scale a bitmap on a canvas using bicubic interpolation in Android?

查看:294
本文介绍了如何画和规模在Android中使用双三次插值在画布上的位图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要画在画布上的位图具有更大的尺寸比它。我可以使用canvas.drawBitmap(位图,空,destRect,NULL);但是,给出了一个质量差,作为结果被像素化,如果源图像是悦目比目标矩形小。

I want to draw a bitmap on a canvas with bigger size than it is. I can use canvas.drawBitmap(bitmap, null, destRect, null); but that gives a poor quality, as the result is pixelated, if the source image is sightly smaller than the destination rectangle.

我怎样才能使用双线性或双三次重采样得出我的位图?

How can i draw my bitmap using bilinear or bicubic resampling?

任何帮助将是AP preciated,感谢名单。

Any help would be appreciated, thanx.

推荐答案

您需要设置FILTER_BITMAP_FLAG标志的油漆。

You need to set the FILTER_BITMAP_FLAG flag in your paint.

canvas.drawBitmap(bitmap, matrix, null); //ugly jaggies unless scale is 1:1, but fast

Paint paint = new Paint();
paint.setFilterBitmap();
canvas.drawBitmap(bitmap, matrix, paint); // pretty but slower (not too slow, usually)

这同样适用于 drawBitmap 法的其他(语法糖)的形式。

The same applies to other (syntactic sugar) forms of the drawBitmap method.

有对大多数的Andr​​oid的绘图选项的任何地方没有文件既不是有底层的本地库Skia的,做渲染文档。如果有我会更开心。您可以搜索在谷歌code搜索的Skia的源$ C ​​$ C。搜索Skia的和深入的原料来源;这是唯一的文档。

There is no documentation anywhere for most of the Android drawing options and neither is there documentation for the underlying native Skia library that does the rendering. I'd be happier if there were. You can search the Skia source code on Google Code Search. Search for Skia and dig into the raw source; that's the only documentation.

这篇关于如何画和规模在Android中使用双三次插值在画布上的位图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆