Advertisement
Guest User

Untitled

a guest
Dec 18th, 2014
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. /**
  2. * 画像を合成する
  3. *
  4. */
  5. - (UIImage *)compositeImages:(NSArray *)array size:(CGSize)size
  6. {
  7. UIImage *image = nil;
  8.  
  9. // ビットマップ形式のグラフィックスコンテキストの生成
  10. UIGraphicsBeginImageContextWithOptions(size, NO, 0);
  11.  
  12. // 描画領域
  13. CGRect rect = CGRectMake(0, 0, size.width, size.height);
  14.  
  15. for (id item in array) {
  16. if (![item isKindOfClass:[UIImage class]]) {
  17. continue;
  18. }
  19. UIImage *img = item;
  20. [img drawInRect:rect];
  21. }
  22.  
  23. // 現在のグラフィックスコンテキストの画像を取得する
  24. image = UIGraphicsGetImageFromCurrentImageContext();
  25.  
  26. // 現在のグラフィックスコンテキストへの編集を終了
  27. // (スタックの先頭から削除する)
  28. UIGraphicsEndImageContext();
  29.  
  30. return image;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement