Skip to content

Commit

Permalink
AvatarGenerator: add sanity check
Browse files Browse the repository at this point in the history
  • Loading branch information
giomfo committed Mar 8, 2017
1 parent 70ab051 commit de4e489
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions Vector/Utils/AvatarGenerator.m
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,14 @@ + (UIImage *)imageFromText:(NSString*)text withBackgroundColor:(UIColor*)color

// set to the top quality
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetInterpolationQuality(context, kCGInterpolationHigh);
[[backgroundLabel layer] renderInContext: UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIImage *image;
if (context)
{
CGContextSetInterpolationQuality(context, kCGInterpolationHigh);
[[backgroundLabel layer] renderInContext: context];
image = UIGraphicsGetImageFromCurrentImageContext();
}

UIGraphicsEndImageContext();

// Return the image.
Expand All @@ -127,9 +132,14 @@ + (UIImage *)imageFromText:(NSString*)text withBackgroundColor:(UIColor*)color s

// set to the top quality
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetInterpolationQuality(context, kCGInterpolationHigh);
[[bgLabel layer] renderInContext: UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIImage *image;
if (context)
{
CGContextSetInterpolationQuality(context, kCGInterpolationHigh);
[[bgLabel layer] renderInContext: context];
image = UIGraphicsGetImageFromCurrentImageContext();
}

UIGraphicsEndImageContext();

// Return the image.
Expand Down

0 comments on commit de4e489

Please sign in to comment.