Permalink
Browse files

Merge pull request #1243 from julapy/bugfix-ios-videoGrabber

ios video grabber orientation fix
  • Loading branch information...
2 parents 4aa85f7 + 13dda35 commit e43c9813efb7650ae510070b944c803ed79d1c9a @ofTheo ofTheo committed May 6, 2012
Showing with 13 additions and 8 deletions.
  1. +13 −8 addons/ofxiPhone/src/AVFoundationVideoGrabber.mm
@@ -324,24 +324,29 @@ - (void)eraseGrabberPtr {
spriteContext = CGBitmapContextCreate(pixelsTmp, width, height, CGImageGetBitsPerComponent(ref), width * 4, CGImageGetColorSpace(ref), kCGImageAlphaPremultipliedLast);
if(ofxiPhoneGetOrientation() == UIDeviceOrientationPortrait) {
- transform = CGAffineTransformMakeTranslation(0.0, height);
- transform = CGAffineTransformRotate(transform, 3.0 * M_PI / 2.0);
+ transform = CGAffineTransformMakeTranslation(0.0, height);
+ transform = CGAffineTransformRotate(transform, 3.0 * M_PI / 2.0);
- CGContextConcatCTM(spriteContext, transform);
- CGContextDrawImage(spriteContext, CGRectMake(0.0, 0.0, (CGFloat)height, (CGFloat)width), ref);
+ CGContextConcatCTM(spriteContext, transform);
+ CGContextDrawImage(spriteContext, CGRectMake(0.0, 0.0, (CGFloat)height, (CGFloat)width), ref);
}
else if(ofxiPhoneGetOrientation() == UIDeviceOrientationPortraitUpsideDown) {
- ofLog(OF_LOG_WARNING, "upsidedown orientation not supported at this time"); // TODO support this
+ transform = CGAffineTransformMakeTranslation(width, 0.0);
+ transform = CGAffineTransformRotate(transform, M_PI / 2.0);
+
+ CGContextConcatCTM(spriteContext, transform);
+ CGContextDrawImage(spriteContext, CGRectMake(0.0, 0.0, (CGFloat)height, (CGFloat)width), ref);
}
else if(ofxiPhoneGetOrientation() == UIDeviceOrientationLandscapeLeft) {
+ CGContextDrawImage(spriteContext, CGRectMake(0.0, 0.0, (CGFloat)width, (CGFloat)height), ref);
+ }
+ else { // landscape RIGHT
transform = CGAffineTransformMakeTranslation(width, height);
transform = CGAffineTransformScale(transform, -1.0, -1.0);
CGContextConcatCTM(spriteContext, transform);
CGContextDrawImage(spriteContext, CGRectMake(0.0, 0.0, (CGFloat)width, (CGFloat)height), ref);
- }
- else // landscape RIGHT
- CGContextDrawImage(spriteContext, CGRectMake(0.0, 0.0, (CGFloat)width, (CGFloat)height), ref);
+ }
CGContextRelease(spriteContext);

0 comments on commit e43c981

Please sign in to comment.