Created
December 18, 2014 08:58
-
-
Save hirokim/2c29959d4a896493473e to your computer and use it in GitHub Desktop.
画像を合成する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 画像を合成する | |
* | |
*/ | |
- (UIImage *)compositeImages:(NSArray *)array size:(CGSize)size | |
{ | |
UIImage *image = nil; | |
// ビットマップ形式のグラフィックスコンテキストの生成 | |
UIGraphicsBeginImageContextWithOptions(size, NO, 0); | |
// 描画領域 | |
CGRect rect = CGRectMake(0, 0, size.width, size.height); | |
for (id item in array) { | |
if (![item isKindOfClass:[UIImage class]]) { | |
continue; | |
} | |
UIImage *img = item; | |
[img drawInRect:rect]; | |
} | |
// 現在のグラフィックスコンテキストの画像を取得する | |
image = UIGraphicsGetImageFromCurrentImageContext(); | |
// 現在のグラフィックスコンテキストへの編集を終了 | |
// (スタックの先頭から削除する) | |
UIGraphicsEndImageContext(); | |
return image; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment