This might be something others find useful in relation to grabscreen…I was having an issue with the iphonescreengrab only returning portrait photos to the photo album, but the image saving function wasn’t calling all of the setter methods, in particular the image orientation, so I added that in with an if statement to decide when to use each one depending on how you’re holding the device
This is my “quick” method of modifying it, but I’m sure there is a more efficient way to do it…
At the very end of the ofxiPhoneScreenGrab function, comment out this:
//UIImage *image = [[UIImage alloc] initWithCGImage:imageRef];
and delete everything below it, and add in this stuff (all below CGDataProviderRelease)
if ([UIDevice currentDevice].orientation==UIDeviceOrientationLandscapeLeft ||
[UIDevice currentDevice].orientation==UIDeviceOrientationUnknown||
[UIDevice currentDevice].orientation==UIDeviceOrientationPortrait||
[UIDevice currentDevice].orientation==UIDeviceOrientationFaceUp||
[UIDevice currentDevice].orientation==UIDeviceOrientationFaceDown)
{ //If the user is not holding the device portrait, make photo landscape left
UIImage *image = [[UIImage alloc] initWithCGImage:imageRef scale:1.0 orientation:UIImageOrientationLeft];
CGImageRelease(imageRef);
SaveDelegate *saveDelegate = [SaveDelegate new];
saveDelegate.delegate = delegate;
UIImageWriteToSavedPhotosAlbum(image, saveDelegate, @selector(image:didFinishSavingWithError:contextInfo:), nil);
}
else if([UIDevice currentDevice].orientation==UIDeviceOrientationLandscapeRight) { //Landscape Right
UIImage *image = [[UIImage alloc] initWithCGImage:imageRef scale:1.0 orientation:UIImageOrientationRight];
CGImageRelease(imageRef);
SaveDelegate *saveDelegate = [SaveDelegate new];
saveDelegate.delegate = delegate;
UIImageWriteToSavedPhotosAlbum(image, saveDelegate, @selector(image:didFinishSavingWithError:contextInfo:), nil);
}
else if([UIDevice currentDevice].orientation==UIDeviceOrientationPortrait || [UIDevice currentDevice].orientation==UIDeviceOrientationPortraitUpsideDown) {
//Portrait only
UIImage *image = [[UIImage alloc] initWithCGImage:imageRef scale:1.0 orientation:UIImageOrientationUp];
CGImageRelease(imageRef);
SaveDelegate *saveDelegate = [SaveDelegate new];
saveDelegate.delegate = delegate;
UIImageWriteToSavedPhotosAlbum(image, saveDelegate, @selector(image:didFinishSavingWithError:contextInfo:), nil);
}