美文网首页
图片字符串互相转换

图片字符串互相转换

作者: CarrieQ | 来源:发表于2016-11-29 11:49 被阅读6次
//图片转字符串

- (NSString *)UIImageToBase64Str:(UIImage *) image

{

    NSData *data = UIImageJPEGRepresentation(image, 1.0f);

    NSString *encodedImageStr = [data base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];

    return encodedImageStr;

}

//字符串转图片

- (UIImage *)Base64StrToUIImage:(NSString *)_encodedImageStr

{

    NSData *_decodedImageData = [[NSData alloc] initWithBase64Encoding:_encodedImageStr];

    UIImage *_decodedImage = [UIImage imageWithData:_decodedImageData];

    return _decodedImage;

}

相关文章

网友评论

      本文标题:图片字符串互相转换

      本文链接:https://www.haomeiwen.com/subject/ywmapttx.html