Caps-iOS/CapCollector/Extensions/CGImagePropertyOrientation+Extensions.swift

34 lines
898 B
Swift
Raw Normal View History

2020-05-16 11:21:55 +02:00
//
// CGImagePropertyOrientation+Extensions.swift
// CapCollector
//
// Created by Christoph on 13.05.20.
// Copyright © 2020 CH. All rights reserved.
//
import UIKit
extension CGImagePropertyOrientation {
/**
Converts a `UIImageOrientation` to a corresponding
`CGImagePropertyOrientation`. The cases for each
orientation are represented by different raw values.
- Tag: ConvertOrientation
*/
init(_ orientation: UIImage.Orientation) {
switch orientation {
case .up: self = .up
case .upMirrored: self = .upMirrored
case .down: self = .down
case .downMirrored: self = .downMirrored
case .left: self = .left
case .leftMirrored: self = .leftMirrored
case .right: self = .right
case .rightMirrored: self = .rightMirrored
@unknown default:
fatalError()
}
}
}