|
@@ -32,7 +32,7 @@ class NCCreateFormUploadScanDocument: XLFormViewController, NCSelectDelegate, NC
|
|
|
enum typeDpiQuality {
|
|
|
case low
|
|
|
case medium
|
|
|
- case hight
|
|
|
+ case high
|
|
|
}
|
|
|
var dpiQuality: typeDpiQuality = typeDpiQuality.medium
|
|
|
|
|
@@ -92,9 +92,7 @@ class NCCreateFormUploadScanDocument: XLFormViewController, NCSelectDelegate, NC
|
|
|
}
|
|
|
|
|
|
@objc func changeTheming() {
|
|
|
- view.backgroundColor = NCBrandColor.sharedInstance.backgroundForm
|
|
|
- tableView.backgroundColor = NCBrandColor.sharedInstance.backgroundForm
|
|
|
- tableView.reloadData()
|
|
|
+ appDelegate.changeTheming(self, tableView: tableView, collectionView: nil, form: true)
|
|
|
initializeForm()
|
|
|
}
|
|
|
|
|
@@ -263,7 +261,7 @@ class NCCreateFormUploadScanDocument: XLFormViewController, NCSelectDelegate, NC
|
|
|
dpiQuality = typeDpiQuality.medium
|
|
|
} else if compressionQuality > 0.6 && compressionQuality <= 1.0 {
|
|
|
formRow.title = NSLocalizedString("_quality_high_", comment: "")
|
|
|
- dpiQuality = typeDpiQuality.hight
|
|
|
+ dpiQuality = typeDpiQuality.high
|
|
|
}
|
|
|
|
|
|
self.updateFormRow(formRow)
|
|
@@ -659,26 +657,25 @@ class NCCreateFormUploadScanDocument: XLFormViewController, NCSelectDelegate, NC
|
|
|
}
|
|
|
|
|
|
func changeCompressionImage(_ image: UIImage, dpiQuality: typeDpiQuality) -> UIImage {
|
|
|
-
|
|
|
+
|
|
|
var compressionQuality: CGFloat = 0.5
|
|
|
- var maxHeight: Float = 595.2 // A4
|
|
|
- var maxWidth: Float = 841.8 // A4
|
|
|
-
|
|
|
+ var scale: Float = 1.0
|
|
|
+
|
|
|
switch dpiQuality {
|
|
|
- case typeDpiQuality.low:
|
|
|
+ case typeDpiQuality.low: // set to 72 dpi
|
|
|
compressionQuality = 0.1
|
|
|
- case typeDpiQuality.medium:
|
|
|
- maxHeight *= 2
|
|
|
- maxWidth *= 2
|
|
|
+ case typeDpiQuality.medium: // at 150 dpi
|
|
|
compressionQuality = 0.5
|
|
|
- case typeDpiQuality.hight:
|
|
|
- maxHeight *= 4
|
|
|
- maxWidth *= 4
|
|
|
+ scale = (150.0 / 72.0)
|
|
|
+ case typeDpiQuality.high: // at 300 dpi
|
|
|
compressionQuality = 0.9
|
|
|
+ scale = (200.0 / 72.0)
|
|
|
}
|
|
|
|
|
|
- var actualHeight = Float(image.size.height)
|
|
|
- var actualWidth = Float(image.size.width)
|
|
|
+ let maxHeight: Float = Float(595.2) * scale // A4
|
|
|
+ let maxWidth: Float = Float(841.8) * scale // A4
|
|
|
+ var actualHeight = Float(image.size.height * image.scale)
|
|
|
+ var actualWidth = Float(image.size.width * image.scale)
|
|
|
var imgRatio: Float = actualWidth / actualHeight
|
|
|
let maxRatio: Float = maxWidth / maxHeight
|
|
|
|
|
@@ -702,7 +699,7 @@ class NCCreateFormUploadScanDocument: XLFormViewController, NCSelectDelegate, NC
|
|
|
}
|
|
|
|
|
|
let rect = CGRect(x: 0.0, y: 0.0, width: CGFloat(actualWidth), height: CGFloat(actualHeight))
|
|
|
- UIGraphicsBeginImageContext(rect.size)
|
|
|
+ UIGraphicsBeginImageContextWithOptions(rect.size, false, image.scale)
|
|
|
image.draw(in: rect)
|
|
|
let img = UIGraphicsGetImageFromCurrentImageContext()
|
|
|
let imageData = img?.jpegData(compressionQuality: CGFloat(compressionQuality))
|