开发者

Accessing image file contents after UIImagePicker selection

开发者 https://www.devze.com 2023-03-09 06:34 出处:网络
I have a UIImagePicker selection, and on the selection of an image it returns an info dictionary with the following entries:

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

精彩评论

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