簡體   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