Android Studio 中的图片尺寸 Java
Picture Size in Android Studio with Java
这是一个初学者问题,所以如果它很基础,我深表歉意。我已经用谷歌搜索,但我发现的 questions/answers 比我能够理解的要复杂得多。我正在尝试在 Android Studio 中为 Android 制作相机应用程序。我知道我可以访问默认摄像头,但我需要在应用程序中进行操作。
到目前为止,我的应用程序确实显示了预览,并且可以成功拍摄和保存照片。
我正在关注相机 API 页面:https://developer.android.com/guide/topics/media/camera.html#custom-camera
我需要了解如何设置图片大小。现在我可以将它 directly/statically 设置为 2048 x 1536。
这似乎是在这里使用的正确 command/function:https://developer.android.com/reference/android/hardware/Camera.Parameters.html#setPictureSize(int, int)
它给了我这个:void setPictureSize (int width, int height)
My question is - where and how do I implement this? (If I add "setPictureSize(2048,1536)" anywhere in my code, it turns up with a
red line and says "cannot resolve method.")
是否有一些前缀,例如 "Camera.setPictureSize..." 我没有看到任何选项来导入所需的 class/method。
查看如何 Modify Camera Settings 获取更多详细信息,但是对于 setPictureSize,您可以通过从相机实例中检索 Camera.Parameters 来使用它,更改您需要的内容,然后将它们重新设置到相机上.假设您的 Camera 实例名为 mCamera
:
Camera.Parameters params = mCamera.getParameters();
params.setPictureSize(width, height);
mCamera.setParameters(params);
这是一个初学者问题,所以如果它很基础,我深表歉意。我已经用谷歌搜索,但我发现的 questions/answers 比我能够理解的要复杂得多。我正在尝试在 Android Studio 中为 Android 制作相机应用程序。我知道我可以访问默认摄像头,但我需要在应用程序中进行操作。
到目前为止,我的应用程序确实显示了预览,并且可以成功拍摄和保存照片。
我正在关注相机 API 页面:https://developer.android.com/guide/topics/media/camera.html#custom-camera
我需要了解如何设置图片大小。现在我可以将它 directly/statically 设置为 2048 x 1536。
这似乎是在这里使用的正确 command/function:https://developer.android.com/reference/android/hardware/Camera.Parameters.html#setPictureSize(int, int)
它给了我这个:void setPictureSize (int width, int height)
My question is - where and how do I implement this? (If I add "setPictureSize(2048,1536)" anywhere in my code, it turns up with a red line and says "cannot resolve method.")
是否有一些前缀,例如 "Camera.setPictureSize..." 我没有看到任何选项来导入所需的 class/method。
查看如何 Modify Camera Settings 获取更多详细信息,但是对于 setPictureSize,您可以通过从相机实例中检索 Camera.Parameters 来使用它,更改您需要的内容,然后将它们重新设置到相机上.假设您的 Camera 实例名为 mCamera
:
Camera.Parameters params = mCamera.getParameters();
params.setPictureSize(width, height);
mCamera.setParameters(params);