Last active
April 14, 2021 08:16
Revisions
-
eddieespinal renamed this gist
Mar 9, 2016 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
eddieespinal revised this gist
Mar 9, 2016 . 1 changed file with 1 addition and 4 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,3 @@ //This is the swift version of the following gist by @shexbeer https://gist.github.com/shexbeer/cb069d36ca8ec5edb515 func cropCameraImage(original: UIImage, previewLayer: AVCaptureVideoPreviewLayer) -> UIImage? { @@ -30,6 +29,4 @@ } return image } -
eddieespinal revised this gist
Mar 9, 2016 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ `` //This is the swift version of the following gist by @shexbeer https://gist.github.com/shexbeer/cb069d36ca8ec5edb515 func cropCameraImage(original: UIImage, previewLayer: AVCaptureVideoPreviewLayer) -> UIImage? { @@ -29,4 +30,6 @@ } return image } `` -
eddieespinal revised this gist
Mar 9, 2016 . 1 changed file with 1 addition and 5 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,3 @@ //This is the swift version of the following gist by @shexbeer https://gist.github.com/shexbeer/cb069d36ca8ec5edb515 func cropCameraImage(original: UIImage, previewLayer: AVCaptureVideoPreviewLayer) -> UIImage? { @@ -31,6 +29,4 @@ } return image } -
eddieespinal revised this gist
Mar 9, 2016 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ ```swift //This is the swift version of the following gist by @shexbeer https://gist.github.com/shexbeer/cb069d36ca8ec5edb515 func cropCameraImage(original: UIImage, previewLayer: AVCaptureVideoPreviewLayer) -> UIImage? { @@ -32,4 +32,5 @@ return image } ``` -
eddieespinal revised this gist
Mar 9, 2016 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,5 @@ ```javascript //This is the swift version of the following gist by @shexbeer https://gist.github.com/shexbeer/cb069d36ca8ec5edb515 func cropCameraImage(original: UIImage, previewLayer: AVCaptureVideoPreviewLayer) -> UIImage? { -
eddieespinal revised this gist
Mar 9, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ ```javascript //This is the swift version of the following gist by @shexbeer https://gist.github.com/shexbeer/cb069d36ca8ec5edb515 func cropCameraImage(original: UIImage, previewLayer: AVCaptureVideoPreviewLayer) -> UIImage? { -
eddieespinal revised this gist
Mar 9, 2016 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ ```swift //This is the swift version of the following gist by @shexbeer https://gist.github.com/shexbeer/cb069d36ca8ec5edb515 func cropCameraImage(original: UIImage, previewLayer: AVCaptureVideoPreviewLayer) -> UIImage? { @@ -29,4 +30,5 @@ } return image } ``` -
eddieespinal created this gist
Mar 9, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ //This is the swift version of the following gist by @shexbeer https://gist.github.com/shexbeer/cb069d36ca8ec5edb515 func cropCameraImage(original: UIImage, previewLayer: AVCaptureVideoPreviewLayer) -> UIImage? { var image = UIImage() let previewImageLayerBounds = previewLayer.bounds let originalWidth = original.size.width let originalHeight = original.size.height let A = previewImageLayerBounds.origin let B = CGPointMake(previewImageLayerBounds.size.width, previewImageLayerBounds.origin.y) let D = CGPointMake(previewImageLayerBounds.size.width, previewImageLayerBounds.size.height) let a = previewLayer.captureDevicePointOfInterestForPoint(A) let b = previewLayer.captureDevicePointOfInterestForPoint(B) let d = previewLayer.captureDevicePointOfInterestForPoint(D) let posX = floor(b.x * originalHeight) let posY = floor(b.y * originalWidth) let width: CGFloat = d.x * originalHeight - b.x * originalHeight let height: CGFloat = a.y * originalWidth - b.y * originalWidth let cropRect = CGRectMake(posX, posY, width, height) if let imageRef = CGImageCreateWithImageInRect(original.CGImage, cropRect) { image = UIImage(CGImage: imageRef, scale: 2.5, orientation: .LeftMirrored) } return image }