图片 和 base64 互转
程序员文章站
2022-04-09 20:25:34
图片转base64 NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:urlStr]]; UIImage *img = [UIImage imageWithData:data]; NSString *img64 = [ ......
图片转base64
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:urlStr]];
UIImage *img = [UIImage imageWithData:data];
NSString *img64 = [self encodeToBase64String:img];
- (NSString *)encodeToBase64String:(UIImage *)image{
NSString * test = [UIImagePNGRepresentation(image) base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
return test;
}
base64转图片
NSData *data = [[NSData alloc]initWithBase64EncodedString:base64Str options:NSDataBase64DecodingIgnoreUnknownCharacters];
UIImage *img = [UIImage imageWithData:data];
上一篇: Linux shell脚本基础学习详细介绍(完整版)第1/2页
下一篇: Java序列化