gpt4 book ai didi

ios - 屏幕截图不会拍摄 3D 内容

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:35:13 26 4
gpt4 key购买 nike

我正在使用 vuforia-sdk-ios-2-0-32。我引用了下面的截图链接(包括相机和 3D 内容)。 https://developer.vuforia.com/forum/ios/vuforia-sdk-how-take-screenshots , https://developer.vuforia.com/forum/ios/take-screenshot .但是我的代码只拍摄相机图像并保存到相册,但它没有拍摄叠加内容(3D 内容或图像)。

ARParentViewController.mm :

-(void)screenshot:(id)sender{

UIImage *outputImage = nil;

CGFloat scale = [[UIScreen mainScreen] scale];

CGRect s = 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 = [UIImage imageWithCGImage: outputRef];

CGDataProviderRelease(ref);

CGImageRelease(iref);

CGContextRelease(context);

CGImageRelease(outputRef);

free(pixels);

free(buffer);

UIImageWriteToSavedPhotosAlbum(outputImage, nil, nil, nil);

}

AR_EAGLView.mm:

eaglLayer.drawableProperties = @{

kEAGLDrawablePropertyRetainedBacking: [NSNumber numberWithBool:YES],

kEAGLDrawablePropertyColorFormat: kEAGLColorFormatRGBA8,

};

最佳答案

我在我的 ImageTagetEAGlView 中使用了这个方法来拍摄图像和 3d 模型

- (void)savePhoto{

UIGraphicsBeginImageContext(self.frame.size);
[self drawViewHierarchyInRect:self.frame afterScreenUpdates:YES];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
}

注意:我使用的是 Vuforia 4.0

关于ios - 屏幕截图不会拍摄 3D 内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22855620/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com