How to split image?

Discussion in 'iPhone/iPad Programming' started by benc555, Aug 15, 2011.

  1. macrumors newbie

    Joined:
    Nov 29, 2008
    #1
    Hey,
    How can I split a UIImage(in a UIImageView) in half, into 2 different images?

    Thanks!
     
  2. macrumors 6502

    Joined:
    Jul 4, 2009
    #2
    Just wondering ... why?
     
  3. dantastic, Aug 15, 2011
    Last edited: Aug 15, 2011

    macrumors 6502

    dantastic

    Joined:
    Jan 21, 2011
    #3
    off the top of my head now but...

    Code:
    CGRect newImgFrame = CGRectMake(100, 100, 50, 50);
    UIImage *image = [UIImage imageNamed:@"img.png"];
    CGImageRef imageRef = CGImageCreateWithImageInRect(image, newImgFrame);
    image = [UIImage imageWithCGImage:imageRef];
    CGImageRelease(imageRef);
    
    This will leave you with a UIImage in 'image' that is 50x50px taken from 100/100.
     

Share This Page