gpt4 book ai didi

iphone - iOS 上的 UIGraphicsBeginImageContext 与 CGBitmapContextCreate

转载 作者:技术小花猫 更新时间:2023-10-29 10:26:13 27 4
gpt4 key购买 nike

这可能是一个非常愚蠢的问题,但有人能告诉我使用 UIGraphicsBeginImageContext 创建 CGContextRef 和使用 CGBitmapContextCreate 绘制图像之间的区别吗?尤其是现在,因为 UIKit 绘图是线程安全的,我想知道是否有任何理由在 UIGraphicsBeginImageContext 上使用 CGBitmapContextCreate。

最佳答案

根据 Apple 的 UIKit Function Reference ,其封面日期为 2010 年 11 月 15 日,UIGraphicsBeginImageContext 和相关函数仍应仅在主线程上调用。最新 Xcode 3.2.5 附带的开发人员文档中重复了相同的文本。但是,它对 UIGraphicsGetCurrentContext 报告相同,我现在明确认为它是线程安全的。我的理解是只有 UIGraphicsGetCurrentContext 和 UIImage、UIColor 和 UIFont 类现在是线程安全的,而不是整个 UIKit,但我无法找到明确的引用。

无论如何,UIGraphicsBeginImageContext 是一个 UIKit 包装器,它位于 CGBitmapContextCreate 之上并减少了它的功能。特别是,您仅限于具有固定组件顺序的 RGBA 颜色空间图像(尽管它根据 iOS 版本而有所不同)并且无法指定您自己的绘图目标缓冲区。因此,例如,它对于进行一堆 CoreGraphics 合成然后将结果发布到 OpenGL 是无用的,对于将您已经以某种数组形式获得的图形管道传输到 CoreGraphics 也没有帮助。

但是,如果 UIKit 方法支持您需要的功能并且可以安全使用,CoreGraphics 方法就没有内在优势。

关于iphone - iOS 上的 UIGraphicsBeginImageContext 与 CGBitmapContextCreate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4451855/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com