繁体   English   中英

如何与CGBitmapContextCreate和Retina一起使用renderInContext:

[英]How to use renderInContext: with CGBitmapContextCreate and Retina?

我已经手动创建了CGBitmapContext:

bitmapContext = CGBitmapContextCreate( myImageData, width, height, 8, 4 * width, colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big );

并为其绘制一层:

[self.myView.layer renderInContext:bitmapContext];

但是,在Retina上,我的图层仅渲染原始大小的一半。

UIView上设置contentScaleFactor属性不会更改任何内容。

什么是正确的方法?

当然,在我问问题的那一刻,答案就出现了。 只需执行以下操作:

float scale = self.myView.contentScaleFactor;

CGContextScaleCTM(context, scale, scale);

[self.myView.layer renderInContext:context];

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM