Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/115.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
图像编辑iOS_Ios_Objective C - Fatal编程技术网

图像编辑iOS

图像编辑iOS,ios,objective-c,Ios,Objective C,我正在使用AssetPicker图像库。我的问题是,我捕获图像纵向模式并显示图像我的图像视图并将图像水平翻转到图像淀粉状且未正确显示 - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { __weak typeof(self) weakSelf = self;

我正在使用
AssetPicker
图像库。我的问题是,我捕获图像纵向模式并显示图像我的图像视图并将图像水平翻转到图像淀粉状且未正确显示

         - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
           {
          __weak typeof(self) weakSelf = self;

           if (CFStringCompare((CFStringRef) [info   object ForKey:UIImagePickerControllerMediaType], kUTTypeImage, 0) == kCFCompareEqualTo)
             {
           if(self.segmentedControl.selectedSegmentIndex ==1 && self.segmentedControl.hidden == NO)
           {
             self.segmentedControl.selectedSegmentIndex = 0;
            [self changeAssetType:YES endBlock:^{
            _strong typeof(weakSelf) strongSelf = weakSelf;
             UIImage *image = info[UIImagePickerControllerOriginalImage];
            [[NSNotificationCenter defaultCenter] removeObserver:strongSelf  name:ALAssetsLibraryChangedNotification object:nil];
            [strongSelf.assetsLibrary   writeImageToSavedPhotosAlbum:image.CGImage metadata:info[UIImagePickerControllerMediaMetadata] completionBlock:^(NSURL *assetURL, NSError *error) {
                dispatch_async(dispatch_get_main_queue(), ^{
                    [self saveAssetsAction:assetURL error:error           isPhoto:YES];
                 });
                 DLog(@"writeImageToSavedPhotosAlbum");
                }];

             }];

       }
            else
            {
           UIImage *image = info[UIImagePickerControllerOriginalImage];

         [[NSNotificationCenter defaultCenter] removeObserver:self name:ALAssetsLibraryChangedNotification object:nil];
        [self.assetsLibrary writeImageToSavedPhotosAlbum:image.CGImage metadata:info[UIImagePickerControllerMediaMetadata] completionBlock:^(NSURL *assetURL, NSError *error) {
            __strong typeof(weakSelf) strongSelf = weakSelf;
            dispatch_async(dispatch_get_main_queue(), ^{
                [strongSelf saveAssetsAction:assetURL error:error isPhoto:YES];
            });
            DLog(@"writeImageToSavedPhotosAlbum");
        }];
          }
       }
         else 
           {
           if(self.segmentedControl.selectedSegmentIndex ==0 && self.segmentedControl.hidden == NO)
          {
            self.segmentedControl.selectedSegmentIndex = 1;
            [self changeAssetType:NO endBlock:^{
             __strong typeof(weakSelf) strongSelf = weakSelf;

             [[NSNotificationCenter defaultCenter] removeObserver:strongSelf name:ALAssetsLibraryChangedNotification object:nil];
             [strongSelf.assetsLibrary writeVideoAtPathToSavedPhotosAlbum:info[UIImagePickerControllerMediaURL] completionBlock:^(NSURL *assetURL, NSError *error) {
                DLog(@"assetURL %@",assetURL);
                dispatch_async(dispatch_get_main_queue(), ^{
                    [self saveAssetsAction:assetURL error:error isPhoto:NO];
                  });
              }];

          }];
        }
              else
       {
          [[NSNotificationCenter defaultCenter] removeObserver:self name:ALAssetsLibraryChangedNotification object:nil];
          [self.assetsLibrary writeVideoAtPathToSavedPhotosAlbum:info[UIImagePickerControllerMediaURL] completionBlock:^(NSURL *assetURL, NSError *error) {
            dispatch_async(dispatch_get_main_queue(), ^{
                [self saveAssetsAction:assetURL error:error isPhoto:NO];
            });

        }];

    }
}

     [picker dismissViewControllerAnimated:YES completion:^{}];


}
水平翻转图像是我的代码

    UIImage *sourceImage = originalimg;

    CIImage *coreImage = [CIImage imageWithCGImage:sourceImage.CGImage];

     UIImage *imgMirror = [UIImage imageWithCIImage:coreImage scale:sourceImage.scale orientation:UIImageOrientationUpMirrored];

     CGRect rect = CGRectMake(0, 0, originalimg.size.width, originalimg.size.height);

      UIGraphicsBeginImageContext(rect.size);

    [imgMirror drawInRect:rect];

    originalimg = UIGraphicsGetImageFromCurrentImageContext();

    imgview2.image = originalimg;
UIGraphicsEndImageContext();

将图像宽度的值与图像高度交换

CGRect rect=CGRectMake(0,0,originalimg.size.height,originalimg.size.width)

您的图像被拉伸,因为如果您正在使用 尺寸400X800(纵向模式),则新翻转的图像也会 使用400X800尺寸而不是800X400创建


你的问题/工作很不清楚。。。你是说你的图像被拉伸了,这就是问题所在吗?你现在应该有足够的信誉点来上传一张显示失败的图像。我们不知道你需要什么。。。