"We offer new support options and therefor the forums are now in read-only mode! Please check out our Support Center for more information." - Vuforia Engine Team

Screenshot in portrait mode

Hi,

Below code takes screenshot in landscpe mode correctly but when camera is in protrait then still it takes landscape photo. How can I make it work for both orientations.

 

UIImage *outputImage = nil;    CGFloat scale = 1.0;    if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) {        scale = [[UIScreen mainScreen] scale];    }    VideoPlaybackAppDelegate *delegate = (VideoPlaybackAppDelegate *)[UIApplication sharedApplication].delegate;    CGRect s;    UIViewController *contr = (UIViewController *)delegate.arParentViewController;    if (UIDeviceOrientationIsLandscape(contr.interfaceOrientation)) {        s = CGRectMake(0, 0, 480.0f * scale, 320.0f * scale);     }    else if (UIDeviceOrientationIsPortrait(contr.interfaceOrientation)) {        s = CGRectMake(0, 0, 320.0f * scale, 480.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);        return outputImage;

Hi

Have a look at this link on the Apple developer web site that shows how to capture screenshots and also how to extend this to OpenGL ES buffers.

http://developer.apple.com/library/ios/#qa/qa1703/_index.html

HTH

N