简体   繁体   English

在Objective-C中查找UIImage的文件路径

[英]Finding filepath of an UIImage in Objective-C

In my app you pick an image using UIImagePickerControllerDelegate, so I have an UIImage. 在我的应用程序中,您使用UIImagePickerControllerDelegate选择一个图像,所以我有一个UIImage。 Now I need the filepath of said image. 现在我需要所述图像的文件路径。

More about the app: I'm trying to modify/edit a selected PNG image. 有关该应用的更多信息:我正在尝试修改/编辑所选的PNG图像。 I need to be able to access each pixel of chosen image. 我需要能够访问所选图像的每个像素。 I have found source code on how to access the pixels but the code relies on loading the image via filepath and I haven't found any way of using the UIImage instead. 我已经找到了有关如何访问像素的源代码,但是代码依赖于通过文件路径加载图像,而我还没有找到使用UIImage的任何方法。 I've tried: 我试过了:

CGImageRef si = [imageView.image CGImage];
CGDataProviderRef src = CGImageGetDataProvider(si);
CGImageRef img = CGImageCreateWithPNGDataProvider(src, NULL, NO, kCGRenderingIntentDefault);

But that only gives me the error: ": CGDataProviderGetSize: size is too large for this function." 但这只给我一个错误:“:CGDataProviderGetSize:此函数的大小太大。”

(See iPhone SDK: accessing indexed color PNG images ) (请参阅iPhone SDK:访问索引的彩色PNG图像

When the image is picked, your delegate gets a callback on imagePickerController:didFinishPickingMediaWithInfo: That call includes an info parameter which is a dictionary. 拾取图像后,您的委托将在imagePickerController:didFinishPickingMediaWithInfo上获得回调:该调用包含一个信息参数 ,该信息参数是字典。 One of the keys gives you the file URL. 键之一为您提供文件URL。 A file URL can be converted to a path using the path method. 可以使用path方法将文件URL转换为路径

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM