标签:io ar os sp for strong on log cti
// 3.图片base64转换
// 先获取压缩图片
UIImage *compressionImage = [selforiginImage:_profileImageView.imagescaleToSize:CGSizeMake(120, 120)];
// 再转换图片
NSData *data = UIImageJPEGRepresentation(compressionImage, 1.0f);
NSString *encodedImageStr = [data base64Encoding];
// 4. 参数发给服务器
[selfupdateUserWithDictionary:@{@"token": token,
@"logo": encodedImageStr
}];
// 上传图片的压缩, 体积变小
-(UIImage*)originImage:(UIImage *)image scaleToSize:(CGSize)size
{
UIGraphicsBeginImageContext(size);
[image drawInRect:CGRectMake(0, 0, size.width, size.height)];
UIImage* scaledImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return scaledImage;
}
// 文字base64 demo
[xmlString appendFormat:@"<contentText>%@</contentText>",[[contentText dataUsingEncoding:NSUTF8StringEncoding] base64Encoding]];
图片压缩base64转换 文字base64加密 上传图片会用到
标签:io ar os sp for strong on log cti
原文地址:http://www.cnblogs.com/liman1990/p/4122658.html