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

  • Home
  • SEARCH
  • 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 738365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:49:41+00:00 2026-05-14T07:49:41+00:00

I’m having a trouble making a re-sizable rectangle for cropping my images. I’m trying

  • 0

I’m having a trouble making a re-sizable rectangle for cropping my images. I’m trying to achieve something like this picture:

http://img192.imageshack.us/img192/8930/customcropbox.jpg

Well, the only problem is I have no clue where to actually start. I need some advice to how I can achieve this effect of cropping. What documentation should I read up on? Core Graphics or Quartz 2d? Both? I’ve been coding for the iPhone since it’s release date but I’ve never actually used core graphics and etc. Any help or advice would be much appreciated. I’ll throw my code up here as I progress to show how it’s done when I achieve it. 🙂 Also, this rectangular box is moveable across the screen in a UIImageView which just makes it more interesting. Thanks for the help and I look forward to achieving this goal.

  • 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-14T07:49:41+00:00Added an answer on May 14, 2026 at 7:49 am

    bookmark my question which is exactly the same.

    I got as far as moving around my cropping view and having it show the portion of the image correctly, but dealing with the scrollview zooming is a work in progress. presently I have an imageview and plain UIView layered in the UIScrollview, then outside of the scrollview and at a higher level is my custom cropping UIView. I implement the touches methods to deal with dragging it around, and also drawRect:

    - (void)drawRect:(CGRect)rect {
        // Drawing code
        if( self.image == nil )
            return;
    
        CGPoint offset = scrollView.contentOffset;
        clipRect = CGRectOffset(self.frame, offset.x, offset.y);
    
        UIImage *croppedImage = [image croppedImage:clipRect];
        CGContextRef ctx = UIGraphicsGetCurrentContext();
        [croppedImage drawAtPoint:CGPointMake(0, 0)];
    }
    

    Note: my cropping view is NOT a descendant of UIImageView, it’s just UIView with a reference to the underlying image from the other view.

    “croppedImage” is a category on UIImage and pretty simple:

    @implementation UIImage (Resize)
    - (UIImage *)croppedImage:(CGRect)bounds {
        CGImageRef imageRef = CGImageCreateWithImageInRect([self CGImage], bounds);
        UIImage *croppedImage = [UIImage imageWithCGImage:imageRef];
        CGImageRelease(imageRef);
        return croppedImage;
    }
    ...
    @end
    

    I’ve implemented a few of the UIScrollViewDelegate methods and pass through scrolling activity so I can keep my cropping view in sync. Zooming is passed along too, but as mentioned, not working as desired yet.

    Another Note: I don’t think it’s necessary to waste the time generating a new UIImage with the cropped area every time as the same should be possible with

    CGImageRef imageRef = CGImageCreateWithImageInRect([yourImage CGImage], bounds);
    and 
    CGContextDrawImage(ctx, clipRect, imageRef);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I am trying to loop through a bunch of documents I have to put
I'm making a simple page using Google Maps API 3. My first. One marker

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.