Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (UIImage *)mergeImage:(UIImage *)bottomImg withImage:(UIImage *)topImg;
- [bottomImg drawInRect:CGRectMake(0, 0, bottomImg.size.width, bottomImg.size.height)];
- [productPhotoImageView.layer renderInContext:ctx];
- UIImage * scaledTopImg = [topImg imageByScalingProportionallyToSize:productPhotoView.frame.size];
- UIImage * rotatedScaledTopImg = [scaledTopImg imageRotatedByDegrees:ANGLE];
- [rotatedScaledTopImg drawAtPoint:CGPointMake(productPhotoView.frame.origin.x, productPhotoView.frame.origin.y)];
- CGImageRef screenImage = UIGetScreenImage();
- CGRect fullRect = [[UIScreen mainScreen] applicationFrame];
- CGImageRef saveCGImage = CGImageCreateWithImageInRect(screenImage, fullRect);
- CGRect cropRect = CGRectMake(x,y,width,height);
- CGImageRef saveCGImage = CGImageCreateWithImageInRect(screenImage, cropRect);
- - (UIImage *)mergeImage:(UIImage *)bottomImg withImage:(UIImage *)topImg {
- UIImage * scaledTopImg = [topImg imageByScalingProportionallyToSize:productPhotoView.frame.size];
- UIGraphicsBeginImageContext(scaledTopImg.size);
- CGContextRef ctx = UIGraphicsGetCurrentContext();
- CGContextTranslateCTM(ctx, scaledTopImg.size.width * 0.5f, scaledTopImg.size.height * 0.5f);
- CGFloat angle = atan2(productPhotoView.transform.b, productPhotoView.transform.a);
- CGContextRotateCTM(ctx, angle);
- [scaledTopImg drawInRect:CGRectMake(- scaledTopImg.size.width * 0.5f, -(scaledTopImg.size.height * 0.5f), scaledTopImg.size.width, scaledTopImg.size.height)];
- UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
- UIGraphicsEndImageContext();
- UIGraphicsBeginImageContext(bottomImg.size);
- [bottomImg drawInRect:CGRectMake(0, 0, bottomImg.size.width, bottomImg.size.height)];
- [newImage drawInRect:CGRectMake(productPhotoView.frame.origin.x, productPhotoView.frame.origin.y, newImage.size.width, newImage.size.height)];
- UIImage *newImage2 = UIGraphicsGetImageFromCurrentImageContext();
- UIGraphicsEndImageContext();
- return newImage2;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement