Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- UIImage* image = imgView.image;
- CGRect r;
- r.origin = CGPointZero;
- r.size = image.size;
- CGFloat scaleFactor = r.size.width * 1.0 / newImage.size.width;
- UIGraphicsBeginImageContext(r.size);
- // draw original image into the context
- [image drawAtPoint:CGPointZero];
- // get the context for CoreGraphics
- CGContextRef ctx = UIGraphicsGetCurrentContext();
- CGContextScaleCTM(ctx, scaleFactor, -1.0 * scaleFactor);
- CGContextTranslateCTM(ctx, 0, r.size.height);
- CGContextBeginTransparencyLayer(ctx, nil);
- CGContextSetAlpha(ctx, .25);
- CGContextDrawImage(ctx, r, CGImageCreateWithImageInRect(newImage.CGImage, r));
- CGContextEndTransparencyLayer(ctx);
- // make image out of bitmap context
- UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
- // free the context
- UIGraphicsEndImageContext();
- [imgView setImage: newImage];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement