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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:56:34+00:00 2026-05-26T23:56:34+00:00

I am working with zoom functionality in AVFoundation camera, i have implemented zoom by

  • 0

I am working with zoom functionality in AVFoundation camera, i have implemented zoom by scaling the view that has AVCaptureVideoPreviewLayer.
Now i want to capture the zoomed image.

here is my code for adding AVFoundationVideoPreviewLayer to view:

 // create a uiview subclass for showing the camera feed
 UIView *previewView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 430)];
 [[self view] addSubview:previewView];

 CGRect layerRect = CGRectMake(0, 0, 320, 430);
 [[self avCaptureVideoPreviewLayer] setBounds:layerRect];

 [[self  previewLayer] setPosition:CGPointMake(CGRectGetMidX(layerRect), CGRectGetMidY(layerRect))];

 // add the video previewview layer to the preview view
 [[previewView layer] addSublayer:[self avCaptureVideoPreviewLayer]];

code for zooming preview view

  // zoom the preview view using core graphics
 [previewView setTransform:CGAffineTransformMakeScale(2.0, 2.0 )];

Now i want to capture this zoomed image from previewView

Thanks in advance.

  • 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-26T23:56:35+00:00Added an answer on May 26, 2026 at 11:56 pm

    Finally i have managed to add capturing zoomed photo in my app. Its a bit ugly but it works. I used UIImage+resize code from the net and then scaled the image to zoom scale, and the calculated the offset position for the zoomed region [that is visible in the camera view] and then i cropped it.

    Now my app crashes sometimes when the zoom scale is at max i.e. at 6x. I am receiving memory problem as the zoomed image is too big, i will ask this as a another question.

    Hoping this code might be usefull for someone.

     if (cameraZoom > 1.0) 
     {
            // save the images original size
            CGSize orgSize = [image size];  
    
            // resize the image to the zoom scale  
            image = [image resizedImage:CGSizeMake(image.size.width * cameraZoom, image.size.height *cameraZoom) interpolationQuality:kCGInterpolationNone];           
    
            // now calculate the offset x and offset y
            CGFloat offsetX = ( image.size.width / 2 ) - (orgSize.width /2) ;
            CGFloat offsetY =  ( image.size.height / 2 ) - (orgSize.height /2);
    
             // crop the image from the offset position to the original width and height
             image = [image croppedImage:CGRectMake(offsetX, offsetY, orgSize.width, orgSize.height)];
        }
    
    
        UIButton *imgBtn = (UIButton *)[self.view viewWithTag:500];
        [imgBtn setImage:image forState:UIControlStateNormal];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on an application that has an image and I want a
I have an ImageView which I want to smoothly zoom on double tap. Currently
I'm working on a app that has a paging UIScrollView that contains three scrollViews
I am working on a project right now that uses an accordion style menu,
I am working on iphone application in which i am showing camera view for
I'm working on an Android application that requires 2D graphical view with a large
i want so zoom a picture. Webkit works fine, but Firefox is not working.
I have the following code working fine, but I'm unable to add a zoom
Working with a SqlCommand in C# I've created a query that contains a IN
Working on a project at the moment and we have to implement soft deletion

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.