【问题标题】:Finding a UIImage file type查找 UIImage 文件类型
【发布时间】:2009-03-17 19:05:31
【问题描述】:

有没有办法确定用于创建 UIImage 的文件类型?

【问题讨论】:

    标签: iphone objective-c cocoa-touch mobile


    【解决方案1】:

    原始图像的类型真的很重要吗?您可以通过检查底层CGImageRef 对象(属性称为CGImage)的详细信息来获取alpha 组件信息等来实现您想要的任何东西吗?

    有关更多详细信息,请从 UIImage 手册页中查找 CGImage 的文档。

    【讨论】:

    • 是的,如果您尝试获取 UIImage 并将其转换为文件并需要知道数据的格式,这很重要。
    【解决方案2】:

    不!

    如果这是您自己加载的图像,您可以将该关联存储在其他地方。如果文件来自其他地方,那么它甚至可能一开始就不是来自文件。

    【讨论】:

      【解决方案3】:

      如果图像是使用 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; 
      
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-10-09
        • 2013-10-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-01-12
        • 2014-08-10
        相关资源
        最近更新 更多