-
Notifications
You must be signed in to change notification settings - Fork 948
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #160 from kevincon/fix-orientation
- Loading branch information
Showing
6 changed files
with
105 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// UIImage+G8FixOrientation.h | ||
// Tesseract OCR iOS | ||
// | ||
// Thanks to `an0` for answer from | ||
// http://stackoverflow.com/a/10611036 | ||
// | ||
// Created by Nikolay Volosatov on 09/01/15. | ||
// Copyright (c) 2014 Daniele Galiotto - www.g8production.com. | ||
// All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface UIImage (G8FixOrientation) | ||
|
||
- (UIImage *)fixOrientation; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// UIImage+G8FixOrientation.m | ||
// Tesseract OCR iOS | ||
// | ||
// Thanks to `an0` for answer from | ||
// http://stackoverflow.com/a/10611036 | ||
// | ||
// Created by Nikolay Volosatov on 09/01/15. | ||
// Copyright (c) 2014 Daniele Galiotto - www.g8production.com. | ||
// All rights reserved. | ||
// | ||
|
||
#import "UIImage+G8FixOrientation.h" | ||
|
||
@implementation UIImage (G8FixOrientation) | ||
|
||
- (UIImage *)fixOrientation | ||
{ | ||
// No-op if the orientation is already correct | ||
if (self.imageOrientation == UIImageOrientationUp) return self; | ||
|
||
UIImage *result; | ||
|
||
UIGraphicsBeginImageContextWithOptions(self.size, NO, self.scale); | ||
|
||
[self drawInRect:(CGRect){0, 0, self.size}]; | ||
result = UIGraphicsGetImageFromCurrentImageContext(); | ||
|
||
UIGraphicsEndImageContext(); | ||
|
||
return result; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters