- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我正在使用 UIImagePickerController 为我的应用程序选择图像。但是,我在保持所选图像的纵横比方面面临一些挑战
例如,
我在手机上有一个原始图像如下(不是正方形图像):
通过'移动和缩放'页面选择iphone上的图片裁剪图片后,结果如下:(这里仍然保持纵横比)
我的应用程序将在带有方形框架 (200 x 200) 的 UIImageView 中显示所选图像。将选定图像设置为 UIImageView (UIImageView.image = selectedImage) 后,图像的宽高比不再保持不变,而是遵循 UIImageView 的框架:(图像现在在我的 UIImageView 中看起来是倾斜的):
在这种情况下,有没有办法保持图像的纵横比?
编辑:更新预期结果
经过一番思考,我意识到解决我的问题的最佳方法是确保对于此类图像(非方形),我需要将它们“转换”为方形图像,即填充图像顶部和底部的空白区域制作一个正方形,例如
预期图像:(添加了顶部和底部边框)
编辑:使用示例代码更新
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfo
{
self.imageView.contentMode = UIViewContentModeScaleAspectFill;
self.imageView.image = image;
[[picker parentViewController] dismissModalViewControllerAnimated:YES];
//Compress image
UIImage *image = [self scaleImage:img toSize:CGSizeMake(612.0,612.0)];
self.imageData = UIImageJPEGRepresentation(image, 0.75);
}
通过添加代码“self.imageView.contentMode = UIViewContentModeScaleAspectFill;”,我能够在 uiimageview 中获取正方形图像
但看起来原始图像仍然不是正方形图像,因此当我执行“UIImage *image = [self scaleImage:img toSize:CGSizeMake(612.0,612.0)];”时仍然会出现倾斜问题。我的假设正确吗?无论如何要缓解这个问题,因为我仍然需要在应用程序的其他地方显示“压缩”图像。
最佳答案
做 myImageView.contentMode = UIViewContentModeScaleAspectFit;
是不够的,因为它以 Zhen 想要的方式改变图像的纵横比,但它不会改变源图像,这就是 Zhen需要。这样做的唯一方法是使用 UIGraphicsImageContext ,如那里所解释的那样: Resize UIImage with aspect ratio?
关于objective-c - Objective-C : How to fix aspect ratio of image (and not change to fit imageview frame),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6674530/
如果没有 Google Fit 应用程序,是否可以使用 Google Fit API? 我想使用 Google Fit API 来计算步数,但是可以在不安装 Google Fit 应用程序的情况下完成
我的应用程序中实现的代码曾经有效,数据已正确插入/显示在 Google Fit 中,但现在不起作用。 我还测试了 BasicHistoryApi 但它不起作用。( https://github.com
我正在努力显示与 Google Fit 应用程序相同的 Activity 历史记录。我在 session 方面做得很好,但我无法正确掌握自动记录的 Activity 。就像示例中的这两个顶级行走一样。
我在使用 Google Fit Api 获取行进距离时遇到问题。我对计步器使用了类似的方法并且有效。它只是说听众已注册。 大部分代码来自 Github 示例。 有什么问题吗? public class
我正在使用此代码尝试检索过去 14 小时内执行的步骤。 YApp myApp = (mYApp) ctx; mGoogleApiClient = myApp.getMyUser();
使用 google fit api 时是否有配额和请求限制?我想使用 google fit api,我很好奇使用它时是否有限制。 最佳答案 您可以在 Google Developer Console
使用 google fit api 时是否有配额和请求限制?我想使用 google fit api,我很好奇使用它时是否有限制。 最佳答案 您可以在 Google Developer Console
无论是使用 fit$loadings 还是使用 fit$Vaccounted 检查它们,我都得到不同的方差值,这些值由因子分析中的因子解释。我正在使用带有 fa() 函数的 psych 包。如果它们应
如果我进入 google api Playground,我会执行以下步骤: 第 1 步:选择并授权 API。我选择两个范围 https://www.googleapis.com/auth/fitnes
我正在执行 https://developers.google.com/fit/android/get-started 中提到的步骤实现一个简单的健身 Android 应用程序。 但是当我想这样做的时
在过去的 6 个月里,我一直在将我的体重输入 Google Fit,现在我想把我的数据拿出来。 访问 Google Fit REST API 不是问题。然而,在所有可访问的数据中找到我的体重数据让我很
我最近尝试尝试使用 Google Fit 应用程序并尝试了 Google Fit developer site 中给出的步骤.并使用了 Android 示例中给出的代码 BasicSensorApi在
我正在创建可以使用 google fit api 的应用程序。 我想获得 google fit 中可用的所有事件( Action )。这里是 google fit 中的事件列表 Reference 。
我尝试了随机森林回归。 代码如下。 import numpy as np from sklearn.preprocessing import StandardScaler from sklearn.m
Google Play documentation claims this is an API_NOT_CONNECTED code ,但是为了访问 Google Fit API,我已经完成了我(认为
我正在使用google javascript api 。为了获取卡路里,我正在使用下一个数据源: 派生:com.google.calories.expished:com.google.android.
我开发了一个需要显示每日步数的应用程序。为此,我使用了 Google Fit SDK 中提供的 API。 似乎一切正常,但我得到的步数与 Google Fit 官方应用程序中显示的步数不匹配。 例如,
我正在尝试从 google fit API 检索用户的每周步数数据,但我从官方 google fit App 数据中获得了不同的步数结果。例如:星期四通过 google fit api 检索到的步数是
我们已经在我们的用户群中发现,自上次 google fit 应用程序更新以来,数据急剧下降,自开始以来,我们一直试图找出代码中的问题。给出时间,我们认为我们使用的版本(当时是 18.0)是问题所在。
拟合高斯混合模型(X-Y数据集)后,如何获取每个分布的参数?例如每个分布的均值、标准差、权重和角度? 我想我可以找到代码 here : def make_ellipses(gmm, ax):
我是一名优秀的程序员,十分优秀!