Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -(UIImage*)scaleToSize:(CGSize)size image:(UIImage*)image
- {
- UIGraphicsBeginImageContext(size);
- // Draw the scaled image in the current context
- [image drawInRect:CGRectMake(0, 0, size.width, size.height)];
- // Create a new image from current context
- UIImage* scaledImage = UIGraphicsGetImageFromCurrentImageContext();
- // Pop the current context from the stack
- UIGraphicsEndImageContext();
- // Return our new scaled image
- return scaledImage;
- }
- -(UIImage *)cropCanvas:(UImage *)input x1:(int)x1 y1:(int)y1 x2:(int)x2 y2:(int)y2{
- CGRect rect = CGRectMake(x1, y1, input.size.width-x2-x1, input.size.height-y2-y1);
- CGImageRef imageref = CGImageCreateWithImageInRect([input CGImage], rect);
- UIImage *img = [UIImage imageWithCGImage:imageref];
- return img;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement