UIImage的,imageWithData在Android的? [英] UIImage, imageWithData in Android?

查看:175
本文介绍了UIImage的,imageWithData在Android的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是相当新的Andr​​oid开发,所以请原谅我,如果这是一个愚蠢的问题。 基本上我有一个iPhone应用程序,这将COM preSS的UIImage到NSData的,使用UIImageJPEGRe presentation方法,这是没有问题的。 当我想读在Android设备上的这些数据的问题开始。我从iPhone的图像数据(NSData的)转移到Android,我想显示在Android上的图像。我应该怎么办呢? 是否有任何自定义类,可以做类似的UIImage imageWithData中的Java功能,即可以去code中的数据,并把它变成位图? 或者我应该尝试连接code和德code。使用一个不同的,但站的方法?如果是这样,有什么选择? 非常感谢你的帮助!

I'm fairly new in Android development so please forgive me if it's a stupid question. Basically I have an iPhone app,which will compress UIImage into NSData, using UIImageJPEGRepresentation method, this is not a problem. The question begins when I am trying to read this data on an Android device. I'm transferring the image data (NSData)from iPhone to Android, and I want to display the image on Android. How should I do so? Is there any customised class that can do function similar to UIImage imageWithData in Java, that can decode the data and turn it into Bitmap? Or should I try to encode and decode using a different but stand method? If so, what are the options? Thank you so much for your help!

推荐答案

在进一步的挖掘和研究,我发现了一些有趣和有用的类,如果有人有兴趣。 <一href="https://$c$c.google.com/p/crossmobile/source/browse/src/xmioslayer/src/org/xmlvm/iphone/?r=68eaa3b2fa6ee05e8034bd517b45b490c50c7bb7" rel="nofollow">https://$c$c.google.com/p/crossmobile/source/browse/src/xmioslayer/src/org/xmlvm/iphone/?r=68eaa3b2fa6ee05e8034bd517b45b490c50c7bb7 这是谷歌跨移动code,有了它们,你可以使用NSData的和其他类中的方法,最初的意思为iOS开发。 然而,这不是我如何解决上述问题。 这里是从iPhone(的UIImage)的图像传递到Android(位图),或其他方式两种方式。 首先,上传图片到自己的服务器上,(在iOS上,不知道Android的使用AFNetwork),然后获取图像的URL,那么这个URL传递给其他设备作为一个字符串。 或者,转换的UIImage到NSData的,然后从NSData的到的NSString(使用Base64Encoding),然后用NSJsonSerializatioin解析什么的NSString,NSArray的NSDictionary的还是以JSON对象。发送JSON对象,并试图去code这在其他设备上。 虽然第一种方法是推荐的,其实我去的第二个,因为我要带或不带网络连接在本地处理数据。 如果有人需要样品code,只问,我会发布。 这就是pretty的太多了!编码快乐!

After further digging and researching, I found some interesting and useful classes if anyone is interested. https://code.google.com/p/crossmobile/source/browse/src/xmioslayer/src/org/xmlvm/iphone/?r=68eaa3b2fa6ee05e8034bd517b45b490c50c7bb7 This is google cross mobile code, with them, you can use NSData and other class method that was originally meant for iOS developing. However that's not how I solve the problem above. There're two ways to pass an image from iPhone(UIImage) to Android(Bitmap), or the other way around. First, upload the image into your own server, (by using AFNetwork in iOS, not sure about android), then get the url of the image, then pass this url to the other device as a string. Or, convert UIImage to NSData, then from NSData to NSString (using Base64Encoding), then use NSJsonSerializatioin to parse whatever NSString, NSArray or NSDictionary to Json Object. Send the Json object, and try to decode it on the other device. Although the first method is recommended, I actually went with the second one since I wish to deal the data locally with or without internet. If anyone needs sample code, just ask, I'll post. And that's pretty much it! Happy coding!

这篇关于UIImage的,imageWithData在Android的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆