0

カメラをセットアップし、カメラの上に Cocos2d レイヤーを追加することができました。今度は、カメラとカメラの上のレイヤーの画像を含むビュー全体のスクリーンショットを撮りたいと思います。

私の CCLayer は透明にされているので、カメラを通して見ることができます。

これを行う方法に関するアイデア/リンク/詳細.. ?

お時間をいただきありがとうございます:)

編集:これはスクリーンショットの私のコードです

UIGraphicsBeginImageContext([CCDirector sharedDirector].openGLView.superview.frame.size);
    [[CCDirector sharedDirector].openGLView.superview.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage * image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndPDFContext();

    CGRect rect;
    rect = CGRectMake(0, 0, 480, 320);
    CGImageRef imageRef = CGImageCreateWithImageInRect([image CGImage],[CCDirector sharedDirector].openGLView.superview.frame);
    UIImage * img =[UIImage imageWithCGImage:imageRef];
    CGImageRelease(imageRef);
    UIImageWriteToSavedPhotosAlbum(img, nil, nil, nil);
4

2 に答える 2

1
 UIGraphicsBeginImageContext(self.view.frame.size); 
 [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; 
 UIImage *viewImage=UIGraphicsGetImageFromCurrentImageContext(); 
 UIGraphicsEndImageContext();

// uiimage を提供します

于 2012-09-12T14:28:42.040 に答える
0

同じものをお探しの方へ..!AVFoundation フレームワークを使用して動作させました。 これは、これを達成する方法に関する1つの素晴らしいチュートリアルです:)

于 2012-09-13T11:16:59.593 に答える