如何解决如何在Xamarin中使用Trilinear过滤或各向异性过滤来过滤位图?
我得到了一个位图图像,以及需要展示的应用程序横幅。
我正在使用此功能:
Bitmap.CreateScaledBitmap(src,width,height,bFilter);
它使用bFilter变量(true / false)确定对我们使用的过滤器,如果为true,则为双线性过滤,否则为Nearest-neighbor。
问题是,结果相同,对我来说都是不好的过滤器,请参见图片:
我的照片:https://i.stack.imgur.com/i5hIZ.png
我需要缩小原始图片的大小,并且这两个滤镜都附带了该滤镜,如您所见,它远非理想,我需要一些帮助。
搜索之后,除了前面提到的2个过滤器外,我找不到使用其他过滤器的解决方案,所以我的问题是:
How to proccess the bitmap with another filter,for example Trilinear or Anisotropic filtering,or any other for that matter?
这是我的代码:
private Bitmap GetBitmap(Drawable d,System.Drawing.Size? bounds)
{
int width = Math.Max(d.IntrinsicWidth,1);
int height = Math.Max(d.IntrinsicHeight,1);
if (bounds.HasValue)
{
width = Math.Min(width,bounds.Value.Width);
height = Math.Min(height,bounds.Value.Height);
}
var bd = d as BitmapDrawable;
if (bd != null)
{
Bitmap src = bd.Bitmap;
if (width == src.Width && height == src.Height)
{
return src;
}
else
{
var bFilter = true;
Android.Util.Log.Debug(TAG,"bFilter:" + bFilter); //<-----choose filter
return Bitmap.CreateScaledBitmap(src,bFilter);
}
}
Bitmap bitmap = Bitmap.CreateBitmap(width,Bitmap.Config.Argb8888);
Canvas canvas = new Canvas(bitmap);
d.SetBounds(0,height);
d.Draw(canvas);
return bitmap;
}
[1]: https://i.stack.imgur.com/i5hIZ.png
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。