ios - 屏幕截图不会拍摄 3D 内容
<p><p>我正在使用 vuforia-sdk-ios-2-0-32。我引用了下面的截图链接(包括相机和 3D 内容)。 <a href="https://developer.vuforia.com/forum/ios/vuforia-sdk-how-take-screenshots" rel="noreferrer noopener nofollow">https://developer.vuforia.com/forum/ios/vuforia-sdk-how-take-screenshots</a> , <a href="https://developer.vuforia.com/forum/ios/take-screenshot" rel="noreferrer noopener nofollow">https://developer.vuforia.com/forum/ios/take-screenshot</a> .但我的代码只拍摄相机图像并保存到相册,但它没有拍摄覆盖内容(3D 内容或图像)。 </p>
<p>ARParentViewController.mm :</p>
<pre><code>-(void)screenshot:(id)sender{
UIImage *outputImage = nil;
CGFloat scale = [ scale];
CGRects = CGRectMake(0, 0, (768.0f) * scale, 1024.0f * scale);
uint8_t *buffer = (uint8_t *) malloc(s.size.width * s.size.height * 4);
glReadPixels(0, 0, s.size.width, s.size.height, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
CGDataProviderRef ref = CGDataProviderCreateWithData(NULL, buffer, s.size.width * s.size.height * 4, NULL);
CGImageRef iref = CGImageCreate(s.size.width, s.size.height, 8, 32, s.size.width * 4, CGColorSpaceCreateDeviceRGB(), kCGBitmapByteOrderDefault, ref, NULL, true, kCGRenderingIntentDefault);
size_t width = CGImageGetWidth(iref);
size_t height = CGImageGetHeight(iref);
size_t length = width * height * 4;
uint32_t *pixels = (uint32_t *)malloc(length);
CGContextRef context = CGBitmapContextCreate(pixels, width, height, 8, width * 4,
CGImageGetColorSpace(iref), kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Big);
CGAffineTransform transform = CGAffineTransformIdentity;
transform = CGAffineTransformMakeTranslation(0.0f, height);
transform = CGAffineTransformScale(transform, 1.0, -1.0);
CGContextConcatCTM(context, transform);
CGContextDrawImage(context, CGRectMake(0.0f, 0.0f, width, height), iref);
CGImageRef outputRef = CGBitmapContextCreateImage(context);
outputImage = ;
CGDataProviderRelease(ref);
CGImageRelease(iref);
CGContextRelease(context);
CGImageRelease(outputRef);
free(pixels);
free(buffer);
UIImageWriteToSavedPhotosAlbum(outputImage, nil, nil, nil);
}
</code></pre>
<p>AR_EAGLView.mm:</p>
<pre><code>eaglLayer.drawableProperties = @{
kEAGLDrawablePropertyRetainedBacking: ,
kEAGLDrawablePropertyColorFormat: kEAGLColorFormatRGBA8,
};
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>我在 ImageTgetEAGlView 中使用了这个方法来拍摄图像和 3d 模型</p>
<pre><code>- (void)savePhoto{
UIGraphicsBeginImageContext(self.frame.size);
;
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
}
</code></pre>
<p>注意:我使用的是 Vuforia 4.0</p></p>
<p style="font-size: 20px;">关于ios - 屏幕截图不会拍摄 3D 内容,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/22855620/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/22855620/
</a>
</p>
页:
[1]