xamarin.forms 中 ImageButton 的自定义图像大小模式

问题描述

情况

我目前正在 xamarin 上探索 android 开发,因此决定开发一个小游戏。

在游戏中,我有一个 ImageButton 来访问一些菜单。例如升级屏幕。 我为图像按钮制作了一些低分辨率图像:

enter image description here

问题

现在,如果我在图像按钮中使用它,图像会被放大,因此看起来很模糊:

enter image description here

我猜,原因是双线性图像大小。

我的具体情况的正确实现是使用最近邻调整大小,因为它保留了低像素外观:

enter image description here

问题

我将如何改变这一点?我找到了 WPF winforms 的代码,但意识到 xamarin 有不同的调用...

class ImageButtonWithHardEdgeExpansion : SomeControl
{
    public InterpolationMode InterpolationMode { get; set; }

    protected override void OnPaint(PaintEventArgs paintEventArgs)
    {
        paintEventArgs.Graphics.InterpolationMode = InterpolationMode;
        base.OnPaint(paintEventArgs);
    }
}

对于中间解决方法,我可以使用外部图像调整器并以高分辨率存储图像......但这对我来说有点违背目的。所以我正在寻找一个更长期的解决方案。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)