IOS图片的切分和合并

来源:互联网 发布:eplan更新主数据 编辑:程序博客网 时间:2024/05/29 17:30

一、图片的切分

    CGImageRef image[10];    for (int i = 0; i < 10; i++) {        CGRect rect;        rect.origin.x = fWidth * i;        rect.origin.y = 0;        rect.size.width = fWidth;        rect.size.height = fHeight;                imageNum[i] = CGImageCreateWithImageInRect([image CGImage], rect);    }
二、图片的合并

    UIGraphicsBeginImageContextWithOptions(self.bounds.size);        UIImage* image1 = [UIImage imageNamed:@"x1.png"];    UIImage* image2 = [UIImage imageNamed:@"x2.png"];    [image1 drawInRect:rect1];    [image2 drawInRect:rect2];        UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();    UIGraphicsEndImageContext();


0 0
原创粉丝点击