嗨,有人可以在Objective-C中将从服务器获取的jpg图像转换为png图像。
实际的问题是通过应用程序,我们在Facebook上共享图像,但是当jpg图像在服务器中上传时,该图像未在facebook中共享。
UIImage * image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:self.imageurl]]]];
我必须将imageurl转换为png格式。
请尝试以下代码:
UIImage *img; // Your image coming from server
NSData *pngData = UIImagePNGRepresentation(img); // Convert it in to PNG data
UIImage *pngImage = [UIImage imageWithData:pngData]; // Result image
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句