PDA

View Full Version : How to split image?




benc555
Aug 15, 2011, 11:47 AM
Hey,
How can I split a UIImage(in a UIImageView) in half, into 2 different images?

Thanks!



ViviUO
Aug 15, 2011, 12:28 PM
Just wondering ... why?

dantastic
Aug 15, 2011, 01:26 PM
off the top of my head now but...


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.