我正在尝试将以上类别用于UIImage
- Found Here
使用的原因是我让用户使用相机/选择器拍照。然后,我需要显示在UIImageView
中选择的图像。
我想保留图像的方向信息,但要稍微缩小,以提高性能并最适合图像视图。
如何实施此类别?我不确定如何打电话给猫,我是否以某种方式调用该方法?
目前,我有一些选择器的委托方法:
#pragma mark - UIImagePickerDelegate Methods
//delegate methode will be called after picking photo either from camera or library
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[self dismissViewControllerAnimated:YES completion:nil];
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
self.collectedImage = image;
NSLog(@"the collect image orientation is: %i",image.imageOrientation);
答案 0 :(得分:0)
self.collectedImage = image;
NSLog(@"--------------------collected image information----------------------");
NSLog(@"the collected image orientation is: %i",image.imageOrientation);
NSLog(@"the image width is: %f",self.collectedImage.size.width);
NSLog(@"the image height is: %f",self.collectedImage.size.height);
// scale the image
UIImage *newCollectedImage = [self.collectedImage scaleWithMaxDimension:([[UIScreen mainScreen] bounds].size.height)];
self.collectedImage = newCollectedImage;
NSLog(@"--------------------collected NEW image information----------------------");
NSLog(@"the new collected image orientation is: %i",self.collectedImage.imageOrientation);
NSLog(@"the new image width is: %f",self.collectedImage.size.width);
NSLog(@"the new image height is: %f",self.collectedImage.size.height);