Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6989363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:12:07+00:00 2026-05-27T19:12:07+00:00

I have some UIViews that have different centers and transforms applied to them. I

  • 0

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)

I am able to get the view rendered in the context to look almost 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 1024×768 ipad screen where as the video buffer is 352 x 288 pixels

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?

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<[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);

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:12:08+00:00Added an answer on May 27, 2026 at 7:12 pm

    Here is the code that made it work for me: note that the 1024, 768 is because the UIImageViews were positioned in the iPad coordinate system. The rotations are inverted though so if someone can find a general solution for that it would be great.

         UIImageView * curr =  your image
         [curr setNeedsDisplay];
         CGContextSaveGState(newContext);
         CGContextScaleCTM(newContext,height/768.0,width/1024.0);
         CGContextTranslateCTM(newContext, 768-curr.center.x, curr.center.y);
         CGContextConcatCTM(newContext, curr.transform);
         CGContextTranslateCTM(newContext, -curr.bounds.size.width/2, -curr.bounds.size.height/2);
         [curr.layer renderInContext:newContext];
         CGContextRestoreGState(newContext);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that UIViews may transforms have applied to them , some of which
I have some UIImageViews that are nested in UIViews, which group them together. They're
I have some files that are uuencoded, and I need to decode them, using
I have a method that is performing some arithmetic on a set of UIViews
I have a NIB with a UIView that contains some UILabels, UIButtons etc. and
I have some buttons in an UIView. My problem is, that they get cut
I have some script in my default page that redirects users to language specific
I have some pretty standard flipping action going on: [UIView beginAnimations:@swapScreens context:nil]; [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
I have a set of tiles as UIViews that have a programmable background color,
I have tried this a few different ways but none of them seem to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.