This commit is contained in:
2026-02-10 10:21:21 +08:00
parent cb2e8467a7
commit 4c57f16058
6 changed files with 269 additions and 178 deletions

View File

@@ -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;