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
.
精彩评论