简体   繁体   English

如何防止保存到照片库的图像被调整大小/缩放为全屏?

[英]How to prevent images saved to photo library from being resized/scaled to full screen?

Here is the deal, I have tried using both of the methods shown below to save an image to the photo library. 这是交易,我尝试使用下面显示的两种方法将图像保存到照片库。 Upon saving the image successfully and launching the Photos App to take a look at the image, the app automatically scales/resizes the image to full screen. 成功保存图像并启动“照片”应用以查看图像后,该应用会自动将图像缩放/调整为全屏。

Is there any way to prevent this? 有什么办法可以防止这种情况? It is annoying because to see the whole image the user needs to pinch the image out to show the whole thing. 这很烦人,因为要查看整个图像,用户需要捏合图像以显示整个事物。 I have noticed a few of the more popular camera apps do not have this issue when saving to the photo library. 我注意到一些较流行的相机应用程序在保存到照片库时不存在此问题。 I am curious what method they are using. 我很好奇他们正在使用什么方法。

//Save to Photo Library;
ALAssetsLibrary* library = [[ALAssetsLibrary alloc] init];
//CIImage *ciImage = image.CIImage;
[library writeImageToSavedPhotosAlbum:finalImage.CGImage
                          orientation:ALAssetOrientationUp
                      completionBlock:^(NSURL *assetURL, NSError *error) {
                          NSlog(@"Done");
                      }];

Save to Photo Library;
UIImageWriteToSavedPhotosAlbum(savedPhoto,nil,nil,nil);

Thank you for your help! 谢谢您的帮助!

After doing a bit of research there is no solution to this problem. 经过一些研究后,没有解决此问题的方法。 The photos app automatically scales up the image to fill the screen. 照片应用会自动按比例放大图像以填满整个屏幕。

Thanks for all of the responses. 感谢您的所有回复。

Saving image should be fine. 保存图像应该没问题。

I think you can set UIView property UIViewContentMode, when you using the image. 我认为您可以在使用图像时设置UIView属性UIViewContentMode。

typedef enum {
UIViewContentModeScaleToFill,
UIViewContentModeScaleAspectFit,      // contents scaled to fit with fixed aspect. remainder is transparent
UIViewContentModeScaleAspectFill,     // contents scaled to fill with fixed aspect. some portion of content may be clipped.
UIViewContentModeRedraw,              // redraw on bounds change (calls -setNeedsDisplay)
UIViewContentModeCenter,              // contents remain same size. positioned adjusted.
UIViewContentModeTop,
UIViewContentModeBottom,
UIViewContentModeLeft,
UIViewContentModeRight,
UIViewContentModeTopLeft,
UIViewContentModeTopRight,
UIViewContentModeBottomLeft,
UIViewContentModeBottomRight,

} UIViewContentMode; } UIViewContentMode;

Hope it helps. 希望能帮助到你。

If you take a look at the FrogScroller sample application from Apple, you'll see they initially load a low-resolution of the image first and then, when zooming use a CATiledLayer with it's size set by the setMaxMinZoomScalesForCurrentBounds function. 如果看一下Apple的FrogScroller示例应用程序,您会看到它们最初会加载低分辨率的图像,然后在缩放时使用CATiledLayer,其大小由setMaxMinZoomScalesForCurrentBounds函数设置。

You might want to look at WWDC 2010's video on scrollViews as well as 2011 for more info. 您可能希望在scrollViews和2011上观看WWDC 2010的视频,以了解更多信息。 Josh and Eliza do a great job explaining what's up. Josh和Eliza很好地解释了最新情况。

为什么在保存之前不将图像分层到具有清晰背景的全屏图像上?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM