Merge branch 'charlesmchen/avatarIconQuality' into release/2.31.0
This commit is contained in:
commit
0cf24e39a8
|
@ -2,17 +2,15 @@
|
|||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "profile-28@1x.png",
|
||||
"filename" : "contact-avatar-1024.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "profile-28@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "profile-28@3x.png",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
BIN
Signal/Images.xcassets/contact-avatar-1024.imageset/contact-avatar-1024.png
vendored
Normal file
BIN
Signal/Images.xcassets/contact-avatar-1024.imageset/contact-avatar-1024.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 34 KiB |
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "contact-avatar-84.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.6 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.0 KiB |
|
@ -100,9 +100,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
- (nullable UIImage *)buildDefaultImage
|
||||
{
|
||||
UIImage *_Nullable cachedAvatar = nil;
|
||||
[OWSContactAvatarBuilder.contactsManager.avatarCache imageForKey:self.cacheKey
|
||||
diameter:(CGFloat)self.diameter];
|
||||
UIImage *_Nullable cachedAvatar =
|
||||
[OWSContactAvatarBuilder.contactsManager.avatarCache imageForKey:self.cacheKey diameter:(CGFloat)self.diameter];
|
||||
if (cachedAvatar) {
|
||||
return cachedAvatar;
|
||||
}
|
||||
|
@ -135,10 +134,18 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
if (initials.length == 0) {
|
||||
// We don't have a name for this contact, so we can't make an "initials" image.
|
||||
|
||||
UIImage *icon = [UIImage imageNamed:@"contact-avatar"];
|
||||
// The contact-avatar asset is designed for the kStandardAvatarSize.
|
||||
UIImage *icon;
|
||||
if (self.diameter > kStandardAvatarSize) {
|
||||
icon = [UIImage imageNamed:@"contact-avatar-1024"];
|
||||
} else {
|
||||
icon = [UIImage imageNamed:@"contact-avatar-84"];
|
||||
}
|
||||
CGFloat assetWidthPixels = CGImageGetWidth(icon.CGImage);
|
||||
// The contact-avatar asset is designed to be 28pt if the avatar is kStandardAvatarSize.
|
||||
// Adjust its size to reflect the actual output diameter.
|
||||
CGFloat scaling = self.diameter / (CGFloat)kStandardAvatarSize;
|
||||
// We use an oversize 1024px version of the asset to ensure quality results for larger avatars.
|
||||
CGFloat scaling = (self.diameter / (CGFloat)kStandardAvatarSize) * (28 / assetWidthPixels);
|
||||
|
||||
CGSize iconSize = CGSizeScale(icon.size, scaling);
|
||||
image =
|
||||
[OWSAvatarBuilder avatarImageWithIcon:icon iconSize:iconSize backgroundColor:color diameter:self.diameter];
|
||||
|
|
Loading…
Reference in New Issue