【发布时间】:2009-03-17 19:05:31
【问题描述】:
有没有办法确定用于创建 UIImage 的文件类型?
【问题讨论】:
标签: iphone objective-c cocoa-touch mobile
有没有办法确定用于创建 UIImage 的文件类型?
【问题讨论】:
标签: iphone objective-c cocoa-touch mobile
原始图像的类型真的很重要吗?您可以通过检查底层CGImageRef 对象(属性称为CGImage)的详细信息来获取alpha 组件信息等来实现您想要的任何东西吗?
有关更多详细信息,请从 UIImage 手册页中查找 CGImage 的文档。
【讨论】:
不!
如果这是您自己加载的图像,您可以将该关联存储在其他地方。如果文件来自其他地方,那么它甚至可能一开始就不是来自文件。
【讨论】:
如果图像是使用 imagePickerController 添加的,您可以在图像选择器委托方法中确定类型,如下所示:
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info {
// Get the image reference URL
NSURL *referenceURL = [info objectForKey:UIImagePickerControllerReferenceURL];
// The path extension contains the image type: JPG, PNG, GIF, etc.
NSString *originalImageType = referenceURL.pathExtension;
}
【讨论】: