|
@@ -406,36 +406,6 @@ class NCUtility: NSObject {
|
|
|
CCUtility.deleteAllChainStore()
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- #if !EXTENSION
|
|
|
- @objc func createAvatard(fileNameSource: String, fileNameSourceAvatar: String, size: CGFloat, borderColor: UIColor, borderWidth: CGFloat) -> UIImage? {
|
|
|
-
|
|
|
- guard let imageFile = UIImage(contentsOfFile: fileNameSource) else { return nil }
|
|
|
- guard let imageSource = imageFile.resizeImage(size: CGSize(width: size, height: size), isAspectRation: true) else { return nil }
|
|
|
-
|
|
|
- UIGraphicsBeginImageContextWithOptions(CGSize(width: size, height: size), false, UIScreen.main.scale)
|
|
|
- imageSource.draw(in: CGRect(x: 0, y: 0, width: size, height: size))
|
|
|
- let image = UIGraphicsGetImageFromCurrentImageContext()
|
|
|
- UIGraphicsEndImageContext()
|
|
|
-
|
|
|
- UIGraphicsBeginImageContextWithOptions(CGSize(width: size, height: size), false, UIScreen.main.scale)
|
|
|
- let avatarImageView = NCAvatar.init(image: image, borderColor: borderColor, borderWidth: borderWidth)
|
|
|
- guard let context = UIGraphicsGetCurrentContext() else { return nil }
|
|
|
- avatarImageView.layer.render(in: context)
|
|
|
- guard let imageAvatar = UIGraphicsGetImageFromCurrentImageContext() else { return nil }
|
|
|
- UIGraphicsEndImageContext()
|
|
|
-
|
|
|
- guard let data = imageAvatar.pngData() else {
|
|
|
- return nil
|
|
|
- }
|
|
|
- do {
|
|
|
- try data.write(to: NSURL(fileURLWithPath: fileNameSourceAvatar) as URL, options: .atomic)
|
|
|
- } catch { }
|
|
|
-
|
|
|
- return imageAvatar
|
|
|
- }
|
|
|
- #endif
|
|
|
-
|
|
|
@objc func UIColorFromRGB(rgbValue: UInt32) -> UIColor {
|
|
|
return UIColor(
|
|
|
red: CGFloat((rgbValue & 0xFF0000) >> 16) / 255.0,
|