开发者

Accessing image file contents after UIImagePicker selection

I have a UIImagePicker selection, and on the selection of an image it returns an info dictionary with the following entries:

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

How can I access the BLOB con开发者_JAVA百科tents of the selected image file?


Can't you do this?

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

Alternatively

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

and then access the bytes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜