您好,登錄后才能下訂單哦!
iOS進行合成方式,本人知道的又兩種:
1:使用UIImage直接合成
方法:通過上下文將要合成的圖片都繪制到該上下文,然后得到合成的圖片
- (UIImage*)NTESATCOverlayWith:(UIImage*)overlayImage{
UIGraphicsBeginImageContext(self.size);
[self drawAtPoint:CGPointZero];
[overlayImage drawInRect:CGRectMake(0, 0, self.size.width, self.size.height) blendMode:kCGBlendModeNormal alpha:0.9999999];
UIImage *combinedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return combinedImage;
}
2:通過UIView進行
方法:將圖片都加載到一個UIView上,然后通過UIView生成圖片.
- (UIImage *) p_w_picpathFromView:(UIView *)view {
// we need to size the graphics context according to the device scale
CGFloat scale = [[UIScreen mainScreen] scale];
CGSize pageSize = view.frame.size;
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef context = CGBitmapContextCreate(NULL,
pageSize.width*scale,
pageSize.height*scale,
8, /* bits per component*/
pageSize.width*scale * 4, /* bytes per row */
colorSpace,
kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrderDefault);
CGColorSpaceRelease(colorSpace);
CGContextClipToRect(context, CGRectMake(0, 0, pageSize.width*scale, pageSize.height*scale));
CGContextScaleCTM(context, scale, scale);
[view.layer renderInContext:context];
CGImageRef p_w_picpath = CGBitmapContextCreateImage(context);
CGContextRelease(context);
UIImage *destImaage = [UIImage p_w_picpathWithCGImage:p_w_picpath scale:1 orientation:UIImageOrientationDown | UIImageOrientationDownMirrored];
CGImageRelease(p_w_picpath);
return destImaage;
}
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。