Objective c 如何从图像库中获取真实图像
我想从图书馆得到图片。我使用下面的代码。但它不起作用。我的原始图像大小是2448 × 但是下面代码的结果图像是640x852。我想有原始图像大小2448 X 3264。任何帮助都将不胜感激Objective c 如何从图像库中获取真实图像,objective-c,ios7,Objective C,Ios7,我想从图书馆得到图片。我使用下面的代码。但它不起作用。我的原始图像大小是2448 × 但是下面代码的结果图像是640x852。我想有原始图像大小2448 X 3264。任何帮助都将不胜感激 ALAssetsLibrary *assetLibrary=[[ALAssetsLibrary alloc] init]; [assetLibrary assetForURL:[[self.chosenImages objectAtIndex:i] valueForKe
ALAssetsLibrary *assetLibrary=[[ALAssetsLibrary alloc] init];
[assetLibrary assetForURL:[[self.chosenImages objectAtIndex:i] valueForKey:UIImagePickerControllerReferenceURL] resultBlock:^(ALAsset *asset)
{
ALAssetRepresentation *rep = [asset defaultRepresentation];
uint8_t *buffer = (uint8_t *)malloc(sizeof(uint8_t)*[rep size]);
NSUInteger buffered = (NSInteger )[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
UIImage *myImg =[UIImage imageWithData:data];
NSLog(@"myImg width and height %f and %f",myImg.size.width ,myImg.size.height);
}
failureBlock:^(NSError *err) {
NSLog(@"Error: %@",[err localizedDescription]);
}];
你检查过image.scale属性了吗?最后我发现它是资产库的一个bug。