Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 如何从图像库中获取真实图像_Objective C_Ios7 - Fatal编程技术网

Objective c 如何从图像库中获取真实图像

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

我想从图书馆得到图片。我使用下面的代码。但它不起作用。我的原始图像大小是2448 × 但是下面代码的结果图像是640x852。我想有原始图像大小2448 X 3264。任何帮助都将不胜感激

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。