MonoTouch:在 Retina 显示屏上调整色调时使外观图像尺寸加倍 [英] MonoTouch: Doubling Appearance Image size when Hue adjusted on Retina display

查看:14
本文介绍了MonoTouch:在 Retina 显示屏上调整色调时使外观图像尺寸加倍的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用此代码设置 NavBar 的背景,该代码在 Retina 和非 Retina 显示器中运行良好.有一个@2x 和正常的图像.所以,一切都很好:

I am setting the NavBar's background with this code which works great in Retina and non-Retina displays. There is a @2x and normal image. So, all good:

UINavigationBar.Appearance.SetBackgroundImage(
     GetImage(ImageTheme.menubar), UIBarMetrics.Default);

现在,当我将这个 ChangeHue() 转换应用到图像以调整其色调时,在 Retina 显示器上,图像大小是原来的两倍.非 Retina 显示器没问题:

Now, when I apply this ChangeHue() transformation to the image to adjust its hue, on Retina displays the image is twice the size. Non-Retina displays are fine:

    UINavigationBar.Appearance.SetBackgroundImage(
       ChangeHue(GetImage(ImageTheme.menubar)), UIBarMetrics.Default);
    ...

    UIImage ChangeHue(UIImage originalImage){
        var hueAdjust = new CIHueAdjust() {
            Image = CIImage.FromCGImage(originalImage.CGImage),
            Angle = hue * (float)Math.PI / 180f // angles to radians
        };

        var output = hueAdjust.OutputImage;
        var context = CIContext.FromOptions(null);
        var cgimage = context.CreateCGImage(output, output.Extent);
        var i = UIImage.FromImage(cgimage);
        return i;
}

这是应用色调后非视网膜和视网膜显示的结果:

Here is the result in Non-Retina and Retina displays after the Hue is applied:

推荐答案

向 MonoTouch 团队提交了一个错误.将很快发布解决方案.

Filed a bug with the MonoTouch team. Will post solution shortly.

这篇关于MonoTouch:在 Retina 显示屏上调整色调时使外观图像尺寸加倍的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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