图像数据,iphone Base64的解码问题

编程入门 行业动态 更新时间:2024-10-27 20:28:01
本文介绍了图像数据,iphone Base64的解码问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我从基地64 EN codeD串解码图像数据的一些问题。我使用从以下链接下载base64.h和基础64.m文件

I have some problem for decoding image data from base 64 encoded string. I am using base64.h and base 64.m files downloaded from the following link

cdn.imthi/ e6cef8 /可湿性粉剂内容/上传/ 2010/08 / base64.zip

这是我的code

[Base64 initialize]; NSData * data = [Base64 decode:imageString]; imgview.image=[UIImage imageWithData:data];

但是,没有在图像视图中显示,

but, nothing displayed in the image view ,

我测试由基64字符串(从调试器控制台获取)与网上基地64日codeR解码,它提供了正确的图像,我还通过将数据写入这样一个文件测试

I tested by decoding the base 64 string(taken from debugger console) with an online base 64 decoder,It gives correct image, I also tested by writing the data to a file like this

[data writeToFile:imagePath atomically:YES];

它给出​​了一个JPG文件,但我无法打开图片文件,它提供了错误信息像

it gives a jpg file but i can't open that image file, it gives error message like

文件test.jpg放在无法打开。

The file "test.jpg" could not be opened.

这可能会损坏或使用的文件格式,preVIEW不承认。什么是我的code中的问题谁能帮我.....

"It may be damaged or use a file format that Preview doesn’t recognize." What is the problem with my code Can anyone help me.....

感谢您

推荐答案

尝试不同的基本实施64,我用从一个讨论会的开源项目:

Try a different base 64 implementation, I use the one from colloquy open source project:

#import "NSDataAdditions.h" /* encoded string to image */ NSString *imageString = @""; NSData * data = [NSData dataWithBase64EncodedString:imageString]; UIImage *image1 = [UIImage imageWithData:data]; /* image to encoded string, back to image */ imageString = [UIImagePNGRepresentation(image) base64Encoding]; data = [NSData dataWithBase64EncodedString:imageString]; UIImage *image2 = [UIImage imageWithData:data];

获取 NSAdditions 文件:的 NSAdditions.h + NSAdditions。米

更多推荐

图像数据,iphone Base64的解码问题

本文发布于:2023-10-11 23:58:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1483207.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:图像   数据   iphone

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!