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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:58:06+00:00 2026-05-23T19:58:06+00:00

I want to rotate a image with UIslider control. I have done that with

  • 0

I want to rotate a image with UIslider control.

I have done that with the below function

- (void)rotateImage:(UIImageView *)image duration:(NSTimeInterval)duration 
              curve:(int)curve degrees:(CGFloat)degrees
{
    // Setup the animation
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:duration];
    [UIView setAnimationCurve:curve];
    [UIView setAnimationBeginsFromCurrentState:YES];

// The transform matrix CGAffineTransform transform = CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(degrees)); image.transform = transform; // Commit the changes [UIView commitAnimations];}

by using this function it will work perfect
but the problem is that i can not save the image reference that is rotated.
i have to use that rotated image for further processing.

So how can i save the image that is in Rotated position?

please Help me over this issue

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-23T19:58:07+00:00Added an answer on May 23, 2026 at 7:58 pm

    i found the solution of my question

    use This below method for This

    - (UIImage*)upsideDownBunny:(CGFloat)radians withImage:(UIImage*)testImage {
        __block CGImageRef cgImg;
        __block CGSize imgSize;
        __block UIImageOrientation orientation;
        dispatch_block_t createStartImgBlock = ^(void) {
            // UIImages should only be accessed from the main thread
    
            UIImage *img =testImage
            imgSize = [img size]; // this size will be pre rotated
            orientation = [img imageOrientation];
            cgImg = CGImageRetain([img CGImage]); // this data is not rotated
        };
        if([NSThread isMainThread]) {
            createStartImgBlock();
        } else {
            dispatch_sync(dispatch_get_main_queue(), createStartImgBlock);
        }
        CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
        // in iOS4+ you can let the context allocate memory by passing NULL
        CGContextRef context = CGBitmapContextCreate( NULL,
                                                     imgSize.width,
                                                     imgSize.height,
                                                     8,
                                                     imgSize.width * 4,
                                                     colorspace,
                                                     kCGImageAlphaPremultipliedLast);
        // rotate so the image respects the original UIImage's orientation
        switch (orientation) {
            case UIImageOrientationDown:
                CGContextTranslateCTM(context, imgSize.width, imgSize.height);
                CGContextRotateCTM(context, -radians);
                break;
            case UIImageOrientationLeft:
                CGContextTranslateCTM(context, 0.0, imgSize.height);
                CGContextRotateCTM(context, 3.0 * -radians / 2.0);
                break;
            case UIImageOrientationRight:
                CGContextTranslateCTM(context,imgSize.width, 0.0);
                CGContextRotateCTM(context, -radians / 2.0);
                break;
            default:
                // there are mirrored modes possible
                // but they aren't generated by the iPhone's camera
                break;
        }
        // rotate the image upside down
    
        CGContextTranslateCTM(context, +(imgSize.width * 0.5f), +(imgSize.height * 0.5f));
        CGContextRotateCTM(context, -radians);
        //CGContextDrawImage( context, CGRectMake(0.0, 0.0, imgSize.width, imgSize.height), cgImg );
        CGContextDrawImage(context, (CGRect){.origin.x = -imgSize.width* 0.5f , .origin.y = -imgSize.width* 0.5f , .size.width = imgSize.width, .size.height = imgSize.width}, cgImg);
        // grab the new rotated image
        CGContextFlush(context);
        CGImageRef newCgImg = CGBitmapContextCreateImage(context);
        __block UIImage *newImage;
        dispatch_block_t createRotatedImgBlock = ^(void) {
            // UIImages should only be accessed from the main thread
            newImage = [UIImage imageWithCGImage:newCgImg];
        };
        if([NSThread isMainThread]) {
            createRotatedImgBlock();
        } else {
            dispatch_sync(dispatch_get_main_queue(), createRotatedImgBlock);
        }
        CGColorSpaceRelease(colorspace);
        CGImageRelease(newCgImg);
        CGContextRelease(context);
        return newImage;
    }
    

    call this method with

     UIImage  *rotated2 = [self upsideDownBunny:rotation];
    

    where rotation is sliderValue between 0 to 360.

    now we can save the rotated state.

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

Sidebar

Related Questions

Ok, So I have an Image object that I want to rotate around its
I have an image shown below: I want to rotate this handle when user
My problem is that I want to rotate the UIImageView of a UIButton .
I have an image and want to use three.js to make it so that
I want to rotate an image using ImageView.setImageMatrix(matrix) but it simply doesn't have any
I have an MKAnnotationView where I want to rotate the image property only. If
I want to rotate Image Control using LayoutTransform but the problem i am facing
I want to rotate the below image on a center point using one finger
i want to rotate the image of imageView, i have scaled the image using
hey I have refresh button in HTML and i want to rotate the image

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.