【问题标题】:How to use renderInContext: with CGBitmapContextCreate and Retina?如何使用 renderInContext: 与 CGBitmapContextCreate 和 Retina?
【发布时间】:2013-04-09 23:16:58
【问题描述】:

我已经手动创建了一个 CGBitmapContext:

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

并为其绘制一个图层:

[self.myView.layer renderInContext:bitmapContext];

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

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

这样做的正确方法是什么?

【问题讨论】:

    标签: calayer retina-display cgbitmapcontext


    【解决方案1】:

    当然,在我问这个问题的那一刻,我就得到了答案。只需这样做:

    float scale = self.myView.contentScaleFactor;
    
    CGContextScaleCTM(context, scale, scale);
    
    [self.myView.layer renderInContext:context];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-13
      • 1970-01-01
      • 2012-03-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多