【问题标题】:iPhone camera and photo editing options - integration on custom appiPhone 相机和照片编辑选项 - 自定义应用程序集成
【发布时间】:2012-01-27 12:56:00
【问题描述】:

我现在正处于为新的 iPhone 应用程序收集信息的阶段。对于这个应用程序,我想使用相机和照片图像编辑选项。 Apple 是否提供 API(控制器)让我可以在我的应用程序中使用这种集成的 IO 功能?我的意思是,在一个过程中,首先使用 iPhone 相机(IOS 功能),然后使用照片编辑选项(IOS 功能),压缩并标记它(个人功能),最后将其保存在我的个人应用程序文件夹/库中(不在一般照片库中)?

我一直在阅读 UIImagePickerController 类功能,但我想在继续之前与您再次确认

https://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIImagePickerController_Class/UIImagePickerController/UIImagePickerController.html

有什么想法可以压缩图像或以较低的分辨率捕获图像吗?

非常感谢您

【问题讨论】:

    标签: iphone ios camera


    【解决方案1】:

    您可以在 UIImagePickerController 的回调中调整图像大小,而不是捕获分辨率较低的图像,即

        - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
        UIImage *temp = (UIImage*)[info objectForKey:@"UIImagePickerControllerOriginalImage"];
        UIImage *uploadImage = [self resizeImageWithImage:temp];
    }
    

    调整大小功能:

    - (UIImage*)resizeImageWithImage:(UIImage*)image {
     CGSize newSize = CGSizeMake(newWidth, newHeight);
                    UIGraphicsBeginImageContext( newSize );
                    [image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
                    UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
                    UIGraphicsEndImageContext();
    }
    

    您可能需要使用:

    #import <QuartzCore/QuartzCore.h>
    

    还有图书馆。

    也用于CoreImage库的图像编辑检查,您可以从这里获取信息

    http://developer.apple.com/library/mac/#documentation/graphicsimaging/Conceptual/CoreImaging/ci_intro/ci_intro.html

    【讨论】:

      【解决方案2】:

      对于压缩这可能会有所帮助

      -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
      {
          UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
          NSData *imageData = UIImageJPEGRepresentation(image, 0.6);
          //0 means most compression
          //1 means least compression
      }
      

      【讨论】:

        【解决方案3】:

        UIImagePickerController 将允许用户选择现有照片或拍摄新照片(这取决于您如何设置控制器)。这种方法允许的唯一编辑是让用户裁剪图像。除此之外,您还必须提供自己的功能。

        至于压缩图片,可以保存为JPG,同时定义压缩比,如下:

        NSData *dataForPNGFile = UIImageJPEGRepresentation(yourImage, 0.9f);
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2012-06-12
          • 2010-12-29
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多