Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed videoGrabber orientation issue.

added support for UIDeviceOrientationPortraitUpsideDown.
  • Loading branch information...
commit 13dda35a07229340049a763c9b47858ee7288a79 1 parent 4aa85f7
@julapy julapy authored
Showing with 13 additions and 8 deletions.
  1. +13 −8 addons/ofxiPhone/src/AVFoundationVideoGrabber.mm
View
21 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);
Please sign in to comment.
Something went wrong with that request. Please try again.