美文网首页iOS Developer
iOS 图片转成base64编码

iOS 图片转成base64编码

作者: 在这蓝色天空下 | 来源:发表于2017-02-17 10:46 被阅读3816次

    //UIImage图片转成Base64字符串:

    UIImage *originImage = [UIImage imageNamed:@"originImage.png"];
    NSData *data = UIImageJPEGRepresentation(originImage, 1.0f);
    NSString *encodedImageStr = [data base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
    

    //Base64字符串转UIImage图片:

    NSData *decodedImageData = [[NSData alloc] 
    initWithBase64EncodedString:encodedImageStr options:NSDataBase64DecodingIgnoreUnknownCharacters];
    UIImage *decodedImage = [UIImage imageWithData:decodedImageData];
    

    相关文章

      网友评论

        本文标题:iOS 图片转成base64编码

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