Tag: 图像大小

在iPhone sdk中resize后获取图像的大小

我有图像视图,我正在显示从图书馆中select的图像。 要显示我使用以下方法重新缩放图片的高质量图片。 我得到的图像质量是完美的,但我需要根据新创build的图像的大小设置imageView框架。 但是当我使用newImage.size.width它给我的原始图像视图的宽度。 请帮助我根据显示的图像大小设置图像视图框架。 提前致谢 -(UIImage *)scaleImage:(UIImage *)img toRectSize:(CGRect)screenRect { UIGraphicsBeginImageContext(screenRect.size); float hfactor = img.size.width / screenRect.size.width; float vfactor = img.size.height / screenRect.size.height; float factor = MAX(hfactor, vfactor); float newWidth = img.size.width / factor; float newHeight = img.size.height / factor; float leftOffset = (screenRect.size.width – newWidth) / 2; float topOffset = (screenRect.size.height – newHeight) […]

压缩图像以减小文件大小

我正在构build一个应用程序,让用户拍照或从iPhone上的库中select一个,并将其上传到Parse后端。 我面临的问题是关于文件的大小。 我已经读过关于像Facebook,Twitter,Instagram和Google这样的大玩家在parsing和文件大小方面做了些什么,但是我不能接近它。 我相信他们有最好的代码和工具来做到这一点,但我很乐意尽可能在iOS常规stream程中实现它。 这就是我现在正在做的事情: – (UIImage *)normalResImageForAsset:(ALAsset*)asset { // Convert ALAsset to UIImage UIImage *image = [self highResImageForAsset:asset]; // Determine output size CGFloat maxSize = 1024.0f; CGFloat width = image.size.width; CGFloat height = image.size.height; CGFloat newWidth = width; CGFloat newHeight = height; // If any side exceeds the maximun size, reduce the greater side […]

如何从Xcode 8中的Assets.xcassets添加不同屏幕大小的图片?

我为我的login屏幕创build不同大小的背景图像。 我指的是苹果链接https://developer.apple.com/ios/human-interface-guidelines/graphics/launch-screen/ 但我没有做启动屏幕,我只是想添加背景login屏幕。 我想知道哪个是1x,2x和3x? 另一个问题是当我创build图像集,图像的大小应该拖到哪个地方。 我不知道这件事。 或者我们只需要3张图片(通用行)? 那么,如何为景观图像? 我应该把这个放在哪里?