1
This commit is contained in:
@@ -480,10 +480,10 @@ static NSString * const KBAISelectedPersonaIdKey = @"KBAISelectedPersonaId";
|
||||
[ud setObject:personaDict forKey:@"AppGroup_SelectedPersona"];
|
||||
[ud synchronize];
|
||||
|
||||
NSLog(@"[KBAIHomeVC] 已保存选中的 persona 到 AppGroup: %@, coverImageUrl: %@", persona.name, persona.coverImageUrl);
|
||||
|
||||
NSLog(@"[KBAIHomeVC] 已保存选中的 persona 到 AppGroup: %@, avatarUrl: %@", persona.name, persona.avatarUrl);
|
||||
|
||||
// 异步下载并缩小图片,保存到 AppGroup 共享目录
|
||||
[self downloadAndSavePersonaCoverImage:persona.coverImageUrl];
|
||||
[self downloadAndSavePersonaCoverImage:persona.avatarUrl];
|
||||
}
|
||||
|
||||
/// 下载并缩小 persona 封面图,保存到 AppGroup 共享目录
|
||||
@@ -511,18 +511,17 @@ static NSString * const KBAISelectedPersonaIdKey = @"KBAISelectedPersonaId";
|
||||
return;
|
||||
}
|
||||
|
||||
// 缩小图片到适合键盘扩展的尺寸(宽度 390,高度按比例)
|
||||
CGFloat targetWidth = 390.0;
|
||||
CGFloat scale = targetWidth / image.size.width;
|
||||
CGSize targetSize = CGSizeMake(targetWidth, image.size.height * scale);
|
||||
|
||||
UIGraphicsBeginImageContextWithOptions(targetSize, YES, 1.0);
|
||||
// 缩小图片到 40x40(仅用于工具栏头像显示)
|
||||
CGFloat targetSide = 40.0;
|
||||
CGSize targetSize = CGSizeMake(targetSide, targetSide);
|
||||
|
||||
UIGraphicsBeginImageContextWithOptions(targetSize, NO, 1.0);
|
||||
[image drawInRect:CGRectMake(0, 0, targetSize.width, targetSize.height)];
|
||||
UIImage *scaledImage = UIGraphicsGetImageFromCurrentImageContext();
|
||||
UIGraphicsEndImageContext();
|
||||
|
||||
// 压缩为 JPEG,质量 0.6
|
||||
NSData *jpegData = UIImageJPEGRepresentation(scaledImage, 0.6);
|
||||
|
||||
// 压缩为 JPEG,质量 0.8
|
||||
NSData *jpegData = UIImageJPEGRepresentation(scaledImage, 0.8);
|
||||
if (!jpegData) {
|
||||
NSLog(@"[KBAIHomeVC] 压缩图片失败");
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user