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 7558565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:24:09+00:00 2026-05-30T12:24:09+00:00

I’am doing an app something like this: You load a photo and you put

  • 0

I’am doing an app something like this: You load a photo and you put images over it, like balloons, etc..

When I try to merge one of this over images with only resize it works fine. Like 10px more than it should be but no problem.

The problem comes when you rotate the image [UIImageView] it appears much bigger that the image its, I try allot of things and nothing. I leave the code. I hope someone could help.

Note: The image size its inside UIImageView, then multiplied it by the scale of the main image

- (UIImage *)mergeImage:(UIImageView *)mainImage withImageView:(UIImageView *)imageView {

    UIImage *temp = imageView.image;
    UIImage *tempMain = mainImage.image;

    CGFloat mainScale = [self imageViewScaleFactor:mainImage];
    CGFloat tempScale = 1/mainScale;
    NSLog(@"%f", tempScale);

    //Rotate UIIMAGE
    UIGraphicsBeginImageContext(temp.size);
    CGContextRef ctx = UIGraphicsGetCurrentContext();
    CGAffineTransform transform = CGAffineTransformIdentity;
    transform = CGAffineTransformTranslate(transform, temp.size.width/2, temp.size.height/2);    
    CGFloat angle = atan2(imageView.transform.b, imageView.transform.a);    
    transform = CGAffineTransformRotate(transform, angle);
    transform = CGAffineTransformScale(transform, 1.0, -1.0);
    CGContextConcatCTM(ctx, transform);
    // Draw the image into the context
    CGContextDrawImage(ctx, CGRectMake(-temp.size.width/2, -temp.size.height/2, temp.size.width, temp.size.height), temp.CGImage);
    // Get an image from the context
    temp = [UIImage imageWithCGImage: CGBitmapContextCreateImage(ctx)];


    NSLog(@"%f %f %f", mainScale, mainImage.frame.size.width, mainImage.frame.size.height);

    UIGraphicsBeginImageContextWithOptions(tempMain.size, NO, 1.0f);

    //Get imageView size & position 
    NSLog(@"%f %f %f %f", imageView.frame.origin.x, imageView.frame.origin.y, imageView.frame.size.width, imageView.frame.size.height);

    CGFloat offsetX = 0;
    CGFloat offsetY = -44;

    if (tempMain.size.height > tempMain.size.width) {
        offsetX = ((tempMain.size.width * mainScale) - 320)/2;
    }else{
        offsetY = ((tempMain.size.height * mainScale) - 416)/2;
        offsetY -= 44;
    }

    CGFloat imageViewX = (imageView.frame.origin.x + offsetX) * tempScale;
    CGFloat imageViewY = (imageView.frame.origin.y + offsetY) * tempScale;
    CGFloat imageViewW = imageView.frame.size.width * tempScale;
    CGFloat imageViewH = imageView.frame.size.height * tempScale;


    CGRect tempRect = CGRectMake(imageViewX, imageViewY, imageViewW, imageViewH);


    [tempMain drawAtPoint:CGPointZero];
    [temp drawInRect:tempRect];

    UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    return newImage;
}

Thanks

  • 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-30T12:24:10+00:00Added an answer on May 30, 2026 at 12:24 pm

    This is the solution that works for me

    Merging a previosly rotated by gesture UIImageView with another one. WYS is not WYG

    I just take a photo to the main screen and then crop it to the size of the photo, its faster, and clean. and the resolution it ok if the apps runs in retina in a normal device isn’t too good. And you need to prepare that code to work in retina & non-retina

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am using Paperclip to handle profile photo uploads in my app. They upload
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I am doing a simple coin flipping experiment for class that involves flipping a

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.