How to use renderInContext: with CGBitmapContextCreate and Retina?

I manually created a CGBitmapContext:

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

And draw a layer for it:

 [self.myView.layer renderInContext:bitmapContext]; 

However, on Retina, my layer only displays half of its original size.

Setting the contentScaleFactor property in a UIView does not change anything.

What is the right way to do this?

+4
source share
1 answer

Of course, the answer came to me when I asked the question. Just do the following:

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

All Articles