Use ALAssetsLibrary and ALAsset to take out the NSData of the picture

 Use ALAssetsLibrary and ALAsset to take out the NSData of the picture

1

ALAssetsLibrary * assetLibrary = [[ALAssetsLibrary alloc] init];
  [assetLibrary assetForURL:[[self.imagedata objectAtIndex:i] valueForKey:UIImagePickerControllerReferenceURL] resultBlock:^(ALAsset *asset)
  {
   ALAssetRepresentation * rep = [asset defaultRepresentation];
   Byte *buffer = (Byte*)malloc(rep.size);
   NSUInteger buffered = [rep getBytes:buffer fromOffset:0.0 length:rep.size error:nil];
   NSData *data = [NSData dataWithBytesNoCopy:buffer length:buffered freeWhenDone:YES];//this is NSData may be what you want
   [data writeToFile:photoFile atomically:YES];//you can save image later
  }
  failureBlock:^(NSError *err) {
   NSLog(@"Error: %@",[err localizedDescription]);
  }];

 

2.

UIImage * selImage = [UIImage imageWithCGImage:[asset thumbnail]];  
NSData *baseImage=UIImagePNGRepresentation(selImage);

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326973816&siteId=291194637