Browse Source

new effect

Marino Faggiana 7 years ago
parent
commit
698d3a0823

+ 1 - 1
iOSClient/Images.xcassets/button1000x200.imageset/Contents.json

@@ -2,11 +2,11 @@
   "images" : [
     {
       "idiom" : "universal",
-      "filename" : "button1000x200.png",
       "scale" : "1x"
     },
     {
       "idiom" : "universal",
+      "filename" : "button1000x200@2x.png",
       "scale" : "2x"
     },
     {

+ 0 - 0
iOSClient/Images.xcassets/button1000x200.imageset/button1000x200.png → iOSClient/Images.xcassets/button1000x200.imageset/button1000x200@2x.png


+ 13 - 2
iOSClient/Main/CCDetail.m

@@ -549,8 +549,19 @@
                         [self.photos replaceObjectAtIndex:index withObject:[MWPhoto photoWithImage:[UIImage imageNamed:@"filePreviewError"]]];
                         
                     } else {
+                        /*
+                        UIImage *imageIcon = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.ico", app.directoryUser, metadata.fileID]];
                         
-                        [self.photos replaceObjectAtIndex:index withObject:[MWPhoto photoWithImage:[CCUtility drawText:[NSLocalizedString(@"_loading_", nil) stringByAppendingString:@"..."] inImage:[UIImage imageNamed:@"button1000x200"] colorText:[UIColor darkGrayColor] sizeOfFont:50]]];
+                        if (imageIcon)
+                            image = [CCGraphics scaleImage:imageIcon toSize:self.view.bounds.size isAspectRation:YES];
+
+                            //image = [CCGraphics blurryImage:imageIcon withBlurLevel:2 toSize:self.view.bounds.size];
+                        else
+                        */ 
+                        
+                        image = [CCGraphics drawText:[NSLocalizedString(@"_loading_", nil) stringByAppendingString:@"..."] inImage:[UIImage imageNamed:@"button1000x200"] colorText:[UIColor darkGrayColor] sizeOfFont:50];
+                        
+                        [self.photos replaceObjectAtIndex:index withObject:[MWPhoto photoWithImage:image]];
                     }
                 }
             }
@@ -579,7 +590,7 @@
                         
                     } else {
                         
-                        [self.photos replaceObjectAtIndex:index withObject:[MWPhoto photoWithImage:[CCUtility drawText:[NSLocalizedString(@"_loading_", nil) stringByAppendingString:@"..."] inImage:[UIImage imageNamed:@"button1000x200"] colorText:[UIColor darkGrayColor] sizeOfFont:50]]];
+                        [self.photos replaceObjectAtIndex:index withObject:[MWPhoto photoWithImage:[CCGraphics drawText:[NSLocalizedString(@"_loading_", nil) stringByAppendingString:@"..."] inImage:[UIImage imageNamed:@"button1000x200"] colorText:[UIColor darkGrayColor] sizeOfFont:50]]];
                     }
                 }
             }

+ 1 - 1
iOSClient/Photos/CCPhotos.m

@@ -267,7 +267,7 @@
     
         UIImage *buttonImage = [CCGraphics changeThemingColorImage:[UIImage imageNamed:@"button500x100"] color:[NCBrandColor sharedInstance].brand];
         
-        return [CCUtility drawText:NSLocalizedString(@"_activate_autoupload_", nil) inImage:buttonImage colorText:[UIColor whiteColor] sizeOfFont:26];
+        return [CCGraphics drawText:NSLocalizedString(@"_activate_autoupload_", nil) inImage:buttonImage colorText:[UIColor whiteColor] sizeOfFont:26];
         
     } else return nil;
 }

+ 3 - 1
iOSClient/Utility/CCGraphics.h

@@ -43,7 +43,9 @@
 + (UIColor *)colorFromHexString:(NSString *)hexString;
 + (UIImage *)changeThemingColorImage:(UIImage *)image color:(UIColor *)color;
 
-+ (UIImage *)blurryImage:(UIImage *)image withBlurLevel:(CGFloat)blur;
++ (UIImage*)drawText:(NSString*)text inImage:(UIImage*)image colorText:(UIColor *)colorText sizeOfFont:(CGFloat)sizeOfFont;
+
++ (UIImage *)blurryImage:(UIImage *)image withBlurLevel:(CGFloat)blur toSize:(CGSize)toSize;
 
 @end
 

+ 26 - 2
iOSClient/Utility/CCGraphics.m

@@ -287,11 +287,33 @@
     return [UIImage imageWithCGImage:img.CGImage scale:2.0 orientation: UIImageOrientationDownMirrored];
 }
 
++ (UIImage*)drawText:(NSString*)text inImage:(UIImage*)image colorText:(UIColor *)colorText sizeOfFont:(CGFloat)sizeOfFont
+{
+    NSDictionary* attributes = @{NSFontAttributeName: [UIFont systemFontOfSize:sizeOfFont], NSForegroundColorAttributeName:colorText};
+    NSAttributedString* attributedString = [[NSAttributedString alloc] initWithString:text attributes:attributes];
+    
+    int x = image.size.width/2 - attributedString.size.width/2;
+    int y = image.size.height/2 - attributedString.size.height/2;
+    
+    UIGraphicsBeginImageContext(image.size);
+    
+    [image drawInRect:CGRectMake(0,0,image.size.width,image.size.height)];
+    CGRect rect = CGRectMake(x, y, image.size.width, image.size.height);
+    [[UIColor whiteColor] set];
+    [text drawInRect:CGRectIntegral(rect) withAttributes:attributes];
+    UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
+    newImage = [UIImage imageWithCGImage:newImage.CGImage scale:2 orientation:UIImageOrientationUp];
+    
+    UIGraphicsEndImageContext();
+    
+    return newImage;
+}
+
 // ------------------------------------------------------------------------------------------------------
 // MARK: Blur Image
 // ------------------------------------------------------------------------------------------------------
 
-+ (UIImage *)blurryImage:(UIImage *)image withBlurLevel:(CGFloat)blur
++ (UIImage *)blurryImage:(UIImage *)image withBlurLevel:(CGFloat)blur toSize:(CGSize)toSize
 {
     CIImage *inputImage = [CIImage imageWithCGImage:image.CGImage];
     
@@ -301,7 +323,9 @@
     CIContext *context = [CIContext contextWithOptions:nil];
     CGImageRef outImage = [context createCGImage:outputImage fromRect:[outputImage extent]];
     
-    return [UIImage imageWithCGImage:outImage];
+    UIImage *blurImage = [UIImage imageWithCGImage:outImage];
+    
+    return [CCGraphics scaleImage:blurImage toSize:toSize isAspectRation:YES];
 }
 
 @end

+ 0 - 1
iOSClient/Utility/CCUtility.h

@@ -192,7 +192,6 @@
 + (NSDate *)datetimeWithOutTime:(NSDate *)datDate;
 + (NSDate *)datetimeWithOutDate:(NSDate *)datDate;
 + (BOOL)isValidEmail:(NSString *)checkString;
-+ (UIImage*)drawText:(NSString*)text inImage:(UIImage*)image colorText:(UIColor *)colorText sizeOfFont:(CGFloat)sizeOfFont;
 + (NSString *)URLEncodeStringFromString:(NSString *)string;
 
 @end

+ 0 - 22
iOSClient/Utility/CCUtility.m

@@ -1248,28 +1248,6 @@
     return [emailTest evaluateWithObject:checkString];
 }
 
-+ (UIImage*)drawText:(NSString*)text inImage:(UIImage*)image colorText:(UIColor *)colorText sizeOfFont:(CGFloat)sizeOfFont
-{
-    NSDictionary* attributes = @{NSFontAttributeName: [UIFont systemFontOfSize:sizeOfFont], NSForegroundColorAttributeName:colorText};
-    NSAttributedString* attributedString = [[NSAttributedString alloc] initWithString:text attributes:attributes];
-    
-    int x = image.size.width/2 - attributedString.size.width/2;
-    int y = image.size.height/2 - attributedString.size.height/2;
-    
-    UIGraphicsBeginImageContext(image.size);
-    
-    [image drawInRect:CGRectMake(0,0,image.size.width,image.size.height)];
-    CGRect rect = CGRectMake(x, y, image.size.width, image.size.height);
-    [[UIColor whiteColor] set];
-    [text drawInRect:CGRectIntegral(rect) withAttributes:attributes];
-    UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
-    newImage = [UIImage imageWithCGImage:newImage.CGImage scale:2 orientation:UIImageOrientationUp];
-
-    UIGraphicsEndImageContext();
-    
-    return newImage;
-}
-
 + (NSString *)URLEncodeStringFromString:(NSString *)string
 {
     static CFStringRef charset = CFSTR("!@#$%&*()+'\";:=,/?[] ");