【问题标题】:UIImage UIImageJPEGRepresentation safe to UIImageUIImage UIImageJPEGRepresentation 对 UIImage 安全
【发布时间】:2011-10-10 05:07:37
【问题描述】:

我需要执行 UIImageJPEGRepresentation 方法,然后将其保存到文件中,我需要将其保存到 UIImage。请帮忙..

【问题讨论】:

    标签: objective-c uiimage jpeg representation


    【解决方案1】:

    你可以用这个:

    NSData *imageData = UIImageJPEGRepresentation(uiimageObject,1.0);
    
    UIImage *imageObj = [UIImage imageWithData:imageData];
    

    【讨论】:

      【解决方案2】:

      我不知道您为什么要从 UIImage 转换为 jpeg 数据,然后又回到 UIImage,但 [UIImage imageWithData:jpegdata] 应该这样做。

      【讨论】:

      • 好的,如果有人对此感兴趣的话.. 有解决方案 NSData *tempData = [NSData dataWithData:UIImagePNGRepresentation(image)]; UIImage *tempImage = [UIImage imageWithData:tempData];
      • @mazder:我们都想知道你为什么要这样做,而不是直接使用image
      • @LightNight,步骤太多了。第一部分可以表示为NSData *tempData = UIIMgePNGRepresentation(image);——不需要dataWithData 部分。否则,是的,您的评论会将 UIImage 转换为 NSData 并返回。
      【解决方案3】:

      诶? UIImageJPEGRepresentation图像 转换为 JPEG 数据...

      【讨论】:

      • 我知道,之后我需要将结果保存到 UIImage 而不是本地目录。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多