在UIImagePicker选择之后访问图像文件内容

时间:2011-05-31 15:28:14

标签: ios4 uiimage ipad uiimagepickercontroller

我有一个UIImagePicker选择,在选择图像时,它会返回一个包含以下条目的信息词典:

UIImagePickerControllerMediaType = "public.image"
UIImagePickerControllerOriginalImage = "<UIImage:0x3333333>"
UIImagePickerControllerReferenceURL = "assets-library://asset/asset.JPG?id=1000000001&ext=JPG"

如何访问所选图像文件的BLOB内容?

1 个答案:

答案 0 :(得分:0)

你不能这样做吗?

NSData *data = [NSData dataWithContentsOfURL:[info objectForKey:UIImagePickerControllerReferenceURL]];

<强>替代地

UIImage *image = [info objectForKey: UIImagePickerControllerOriginalImage]; // or you can use UIImagePickerControllerEditedImage too
NSData *data = UIImageJPEGRepresentation(image, 1.0);

然后访问bytes