Note that there are some explanatory texts on larger screens.

plurals
  1. PODrawing using renderInContext in a way that is analagous to UIView rendering
    primarykey
    data
    text
    <p>I have some UIViews that have different centers and transforms applied to them. I want to reconstruct these views on to a bitmap context. (Basically I want to take what the user has created on screen and render it on to a movie file)</p> <p>I am able to get the view rendered in the context to look <em>almost</em> correct however there seems to be an offset. I am thinking the problem is that the UIImageView's .center property is not reflected in the transforms that I am doing. However I am unsure how to do it. Note that the UIViews are originally positioned/transformed relative to a 1024x768 ipad screen where as the video buffer is 352 x 288 pixels</p> <p>If I just add a CGContextTranslateCTM(newContext,img.center.x,img.center.y) then everything looks completely off. Any ideas how to properly transform the view to the correct center?</p> <pre><code>CGContextRef newContext = CGBitmapContextCreate(baseAddress, width, height, 8, bytesPerRow, colorSpace, kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst); CGContextRotateCTM(newContext, M_PI_2); CGContextScaleCTM(newContext, 1, -1); for(int i=0; i&lt;[self.renderObjects count]; i++){ UIImageView * img = [self.renderObjects objectAtIndex:i]; [img setNeedsDisplay]; [img setBackgroundColor:[UIColor colorWithRed:1 green:1 blue:1 alpha:0.2]]; CGContextSaveGState(newContext); CGContextScaleCTM(newContext, 0.375, 0.34); CGContextConcatCTM(newContext, img.transform); [img.layer renderInContext:newContext]; CGContextRestoreGState(newContext); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload