【问题标题】:Which parameter I pass to CGimage for Height n Width我将哪个参数传递给 CGimage 的高度和宽度
【发布时间】:2012-08-06 08:45:28
【问题描述】:

我有一个关于 UIImageView 和 UIImage 的问题,我对一件事感到困惑,即我的 " UIImageView 高度 = 759 和宽度 = 748" 我正在从服务器下载高度和宽度如此的图像所以更大如“图像高度=2048和宽度=2500”

所以我在 UIImageView 上渲染图像时有点困惑,我将参数传递给 CGImage

我将参数传递给 CGImage,如下所示

CGImage _bitmap = new CGImage (2048 , 2500 , 8 , 32 , 2048 * 4 , _colorSpace , CGBitmapFlag.ByteOrderDefault , null, true , CGColorRenderingIntent.Default);

我在 CGImage() 中传递的参数类型意味着我将 Image 参数或 UIImageView 参数传递给 CGImage,以便我的 Image 可以正确呈现到 UIImaeView 中

【问题讨论】:

    标签: c# ios ipad xamarin.ios monodevelop


    【解决方案1】:

    我认为您根本不应该使用CGImage(除非您特别有内存问题)。

    这样做:

    UIImage yourImage;
    //Download from your server here (I can fill it in if needed)
    UIImageView imageView = new UIImageView(new Frame(0, 0, 748, 759)); //This can also be setup in a XIB file
    imageView.ContentMode = UIViewContentMode.ScaleAspectFit;
    imageView.Image = yourImage;
    

    使用内容模式设置来获得您所需要的。

    Here 是内容模式的链接。

    【讨论】:

    • 感谢您的 rlpy 我知道内容模式属性,但它的工作图像不适合 UIImageVIew
    • 当您尝试这种方法时会发生什么?画面是什么样子的,能发个截图吗?这种方法应该适合你。
    • 为什么不检查此链接,以便您找到屏幕截图:-monotouch.2284126.n4.nabble.com/…
    • 这些不是使用我的方法的截图。你仍然在那里使用CGImage。是不是一模一样?
    猜你喜欢
    • 2012-10-04
    • 2021-05-04
    • 2020-09-27
    • 2017-08-14
    • 1970-01-01
    • 1970-01-01
    • 2019-05-05
    • 1970-01-01
    • 2023-04-03
    相关资源
    最近更新 更多