Multiple Clipped Rects to Create Collage in Core Graphics

后端 未结 2 807
天命终不由人
天命终不由人 2021-02-02 03:46

I am creating a collage combined with elements from other images. Here is some ASCII art to explain what I am doing:

Given images A, B and C,
AAA, BBB, CCC
AAA,         


        
2条回答
  •  囚心锁ツ
    2021-02-02 04:33

    The upside down image can be corrected by calling the below method :

    CGImageRef flip (CGImageRef im) {
    CGSize sz = CGSizeMake(CGImageGetWidth(im), CGImageGetHeight(im));
    UIGraphicsBeginImageContextWithOptions(sz, NO, 0);
    CGContextDrawImage(UIGraphicsGetCurrentContext(),
                       CGRectMake(0, 0, sz.width, sz.height), im);
    CGImageRef result = [UIGraphicsGetImageFromCurrentImageContext() CGImage];
    UIGraphicsEndImageContext();
    return result;
    

    }

    Take help from below code as to where u will put this code:

    UIGraphicsBeginImageContextWithOptions(CGSizeMake(leftRect.size.width, leftRect.size.height), NO, 0);
    CGContextRef con = UIGraphicsGetCurrentContext();
    CGContextDrawImage(con, leftRect,flip(leftReference));
    

提交回复
热议问题