<legend id='CRSL3'><style id='CRSL3'><dir id='CRSL3'><q id='CRSL3'></q></dir></style></legend>

        <bdo id='CRSL3'></bdo><ul id='CRSL3'></ul>
      1. <small id='CRSL3'></small><noframes id='CRSL3'>

      2. <tfoot id='CRSL3'></tfoot>
        <i id='CRSL3'><tr id='CRSL3'><dt id='CRSL3'><q id='CRSL3'><span id='CRSL3'><b id='CRSL3'><form id='CRSL3'><ins id='CRSL3'></ins><ul id='CRSL3'></ul><sub id='CRSL3'></sub></form><legend id='CRSL3'></legend><bdo id='CRSL3'><pre id='CRSL3'><center id='CRSL3'></center></pre></bdo></b><th id='CRSL3'></th></span></q></dt></tr></i><div id='CRSL3'><tfoot id='CRSL3'></tfoot><dl id='CRSL3'><fieldset id='CRSL3'></fieldset></dl></div>

        如何从 UIImagePickerController 设置保存图像的分辨率

        How to set the resolution of a saved image from the UIImagePickerController(如何从 UIImagePickerController 设置保存图像的分辨率)

        <tfoot id='BQLSp'></tfoot>
      3. <i id='BQLSp'><tr id='BQLSp'><dt id='BQLSp'><q id='BQLSp'><span id='BQLSp'><b id='BQLSp'><form id='BQLSp'><ins id='BQLSp'></ins><ul id='BQLSp'></ul><sub id='BQLSp'></sub></form><legend id='BQLSp'></legend><bdo id='BQLSp'><pre id='BQLSp'><center id='BQLSp'></center></pre></bdo></b><th id='BQLSp'></th></span></q></dt></tr></i><div id='BQLSp'><tfoot id='BQLSp'></tfoot><dl id='BQLSp'><fieldset id='BQLSp'></fieldset></dl></div>
      4. <small id='BQLSp'></small><noframes id='BQLSp'>

        <legend id='BQLSp'><style id='BQLSp'><dir id='BQLSp'><q id='BQLSp'></q></dir></style></legend>

            <bdo id='BQLSp'></bdo><ul id='BQLSp'></ul>
              <tbody id='BQLSp'></tbody>
                • 本文介绍了如何从 UIImagePickerController 设置保存图像的分辨率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用 UIImagePickerController 将图片从我的相机胶卷设置为 UIImageView.然而,图像在这个 UIImageView 内自动缩放,因为我在 IB 中提到了缩放以适应".我想以 80x80 像素的分辨率保存我选择的图像,这样我就不必缩放了.(由于这个扩展问题,我的应用程序变得非常缓慢.)

                  I'm using an UIImagePickerController to set a picture from my cameraroll to a UIImageView. However the image is getting scaled automaticly inside this UIImageView because I mentioned 'scale to fit' inside the IB. I'd like to save my chosen image with a resolution of 80x80 pixels so that I won't have to scale. (My App is getting realy slow because of this scaling issue.)

                  这是我的代码片段:

                  -(void)imagePickerController:(UIImagePickerController *)picker
                        didFinishPickingImage : (UIImage *)image
                                   editingInfo:(NSDictionary *)editingInfo
                  {
                      [picker dismissModalViewControllerAnimated:YES];
                      UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
                          photoView.image = image;
                  
                  
                          NSString *docDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];       
                          NSString *pngFilePath = [NSString stringWithFormat:@"%@/foto1.png",docDir];
                          NSData *data = [NSData dataWithData:UIImagePNGRepresentation(image)];
                  
                          [data writeToFile:pngFilePath atomically:YES];
                  }
                  

                  非常感谢您的帮助!

                  推荐答案

                  我在这里找到了这段代码:链接

                  I found this code here: Link

                  //  ==============================================================
                  //  resizedImage
                  //  ==============================================================
                  // Return a scaled down copy of the image.  
                  
                  UIImage* resizedImage(UIImage *inImage, CGRect thumbRect)
                  {
                      CGImageRef          imageRef = [inImage CGImage];
                      CGImageAlphaInfo    alphaInfo = CGImageGetAlphaInfo(imageRef);
                  
                      // There's a wierdness with kCGImageAlphaNone and CGBitmapContextCreate
                      // see Supported Pixel Formats in the Quartz 2D Programming Guide
                      // Creating a Bitmap Graphics Context section
                      // only RGB 8 bit images with alpha of kCGImageAlphaNoneSkipFirst, kCGImageAlphaNoneSkipLast, kCGImageAlphaPremultipliedFirst,
                      // and kCGImageAlphaPremultipliedLast, with a few other oddball image kinds are supported
                      // The images on input here are likely to be png or jpeg files
                      if (alphaInfo == kCGImageAlphaNone)
                          alphaInfo = kCGImageAlphaNoneSkipLast;
                  
                      // Build a bitmap context that's the size of the thumbRect
                      CGContextRef bitmap = CGBitmapContextCreate(
                                  NULL,
                                  thumbRect.size.width,       // width
                                  thumbRect.size.height,      // height
                                  CGImageGetBitsPerComponent(imageRef),   // really needs to always be 8
                                  4 * thumbRect.size.width,   // rowbytes
                                  CGImageGetColorSpace(imageRef),
                                  alphaInfo
                          );
                  
                      // Draw into the context, this scales the image
                      CGContextDrawImage(bitmap, thumbRect, imageRef);
                  
                      // Get an image from the context and a UIImage
                      CGImageRef  ref = CGBitmapContextCreateImage(bitmap);
                      UIImage*    result = [UIImage imageWithCGImage:ref];
                  
                      CGContextRelease(bitmap);   // ok if NULL
                      CGImageRelease(ref);
                  
                      return result;
                  }
                  

                  这篇关于如何从 UIImagePickerController 设置保存图像的分辨率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  WebKit on th iPhone: is it possible to copy text to the clipboad with JavaScript(iPhone上的WebKit:是否可以使用JavaScript将文本复制到剪贴板)
                  When compiling for multiple targets in XCode, how do i ensure that certain files will not be included one target(在 XCode 中为多个目标编译时,我如何确保某些文件不会包含在一个目标中)
                  Selecting text in mobile Safari on iPhone(在 iPhone 上的移动 Safari 中选择文本)
                  Draggable UIImageView Partially Transparent amp; Irregular Shaped(可拖动的 UIImageView 部分透明 amp;不规则形状)
                  Add UIImageview in Uitextview as in iMessage(像在 iMessage 中一样在 Uitextview 中添加 UIImageview)
                  Create UIImage from a UIImageView(从 UIImageView 创建 UIImage)
                  <tfoot id='QJpWw'></tfoot>
                • <legend id='QJpWw'><style id='QJpWw'><dir id='QJpWw'><q id='QJpWw'></q></dir></style></legend>
                      <tbody id='QJpWw'></tbody>
                    <i id='QJpWw'><tr id='QJpWw'><dt id='QJpWw'><q id='QJpWw'><span id='QJpWw'><b id='QJpWw'><form id='QJpWw'><ins id='QJpWw'></ins><ul id='QJpWw'></ul><sub id='QJpWw'></sub></form><legend id='QJpWw'></legend><bdo id='QJpWw'><pre id='QJpWw'><center id='QJpWw'></center></pre></bdo></b><th id='QJpWw'></th></span></q></dt></tr></i><div id='QJpWw'><tfoot id='QJpWw'></tfoot><dl id='QJpWw'><fieldset id='QJpWw'></fieldset></dl></div>

                      • <small id='QJpWw'></small><noframes id='QJpWw'>

                        • <bdo id='QJpWw'></bdo><ul id='QJpWw'></ul>