CGContextRef contextRef = CGBitmapContextCreate(NulL,proposedRect.size.wIDth,proposedRect.size.height,CGImageGetBitsPerComponent(imageRef),colorSpaceRef,(CGBitmAPInfo)kCGImageAlphaPremultiplIEdFirst);NSGraphicsContext *context = [NSGraphicsContext graphicsContextWithGraphicsPort:contextRef flipped:NO];
到目前为止,我最终得到了这个:
var bitmapContext: CGContext = CGBitmapContextCreate(data,UInt(proposedRect.wIDth),UInt(proposedRect.height),CGImageGetBitsPerComponent(image),colorSpace,CGBitmAPInfo(CGImageAlphaInfo.PremultiplIEdFirst.toRaw()))let context = NSGraphicsContext(graphicsPort: bitmapContext,flipped: false)
问题是CGBitmapContextCreate返回CGContext类型,NSGraphicsContext初始化程序接受graphicsPort作为CMutableVoIDPointer类型.那么如何将CGContext转换为CMutableVoIDPointer呢?
相关的反向型铸造在这里找到,但它没有给我提供太多帮助
How to convert COpaquePointer in swift to some type (CGContext? in particular)
var bitmapContext: CGContext = CGBitmapContextCreate(...)let bitmapContextAddress: Int = reinterpretCast(bitmapContext)let bitmapContextPointer: CMutableVoIDPointer = copaquePointer(UnsafePointer<CGContext>(bitmapContextAddress))let context = NSGraphicsContext(graphicsPort: bitmapContextPointer,flipped: false)总结
以上是内存溢出为你收集整理的指针 – 在swift中将CFContextRef转换为可变的void指针?全部内容,希望文章能够帮你解决指针 – 在swift中将CFContextRef转换为可变的void指针?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)