Marino Faggiana 6 years ago
parent
commit
a2bae24803
2 changed files with 15 additions and 2 deletions
  1. 3 2
      iOSClient/Offline/NCOffline.swift
  2. 12 0
      iOSClient/Utility/NCUtility.swift

+ 3 - 2
iOSClient/Offline/NCOffline.swift

@@ -627,8 +627,9 @@ class NCOffline: UIViewController ,UICollectionViewDataSource, UICollectionViewD
             } else {
                 cell.imageItem.image = image
                 if imagePreview == false {
-                    cell.imageItem.image = CCGraphics.scale(image, to: CGSize(width: image!.size.width*10, height: image!.size.height*10))
-//                    cell.imageItem.image = CCGraphics.changeThemingColorImage(image, width: image!.size.width*6, height: image!.size.height*6, scale: 3.0, color: nil)
+                    let width = cell.imageItem.image!.size.width * 2
+                    //let scale = UIScreen.main.scale
+                    cell.imageItem.image = NCUtility.sharedInstance.resizeImage(image: image!, newWidth: width)
                     cell.imageItem.contentMode = .center
                 }
             }

+ 12 - 0
iOSClient/Utility/NCUtility.swift

@@ -116,4 +116,16 @@ class NCUtility: NSObject {
         
         return fileID as String
     }
+    
+    func resizeImage(image: UIImage, newWidth: CGFloat) -> UIImage {
+        
+        let scale = newWidth / image.size.width
+        let newHeight = image.size.height * scale
+        UIGraphicsBeginImageContext(CGSize(width: newWidth, height: newHeight))
+        image.draw(in: (CGRect(x: 0, y: 0, width: newWidth, height: newHeight)))
+        let newImage = UIGraphicsGetImageFromCurrentImageContext()!
+        UIGraphicsEndImageContext()
+        
+        return newImage
+    }
 }