Android - 处理图像/相机 - 几个问题
我正在处理 Android 上的图像大小调整问题 - 有趣!这是我希望很小的问题:) 我正在使用相机意图拍照并将其保存在 SD 卡上。
有没有办法获得相机分辨率,以便我知道图像的分辨率,并且不需要每次转换时都检查它?
分辨率是可能改变的还是每个设备固定的?
所有图像都以“横向”格式保存吗?我的意思是它们总是“更宽”而不是“更高”?
如果屏幕上有 ImageView - 我如何知道它需要正确填充什么尺寸的位图?我连续有 4 个 Imageview - 都具有相同的权重,所以我想我需要确定屏幕宽度并适当调整位图大小?
如果我需要将图像缩放到精确宽度 - 这是否意味着我必须计算从 OldX 到 NewX 的“比率”,然后在调用 Bitmap.createScaledBitmap 之前将其应用于 OldY?
I'm dealing with resizing of images on Android - fun! Here is questions I have hopefully small :)
I'm using camera intent to take picture and save it on SD card.
Is there any way to get camera resolution so I will know resolution of image and don't need to check it every time when convert?
Is resolution something that may change or it is fixed per device?
Are all images saved in "landscape" format? I mean they always "wider" than "taller"?
If I have ImageView on a screen - how do I know what size Bitmap it needs to fill properly? I have 4 Imageviews in a row - all with equal weight so I guess I need to come up with screen width and resize Bitmap appropriately?
If I need to scale image to exact width - does it mean I have to calculate "ratio" from OldX to NewX and than apply it to OldY before calling Bitmap.createScaledBitmap?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在寻找 getSupportedPictureSizes() 方法: http ://developer.android.com/reference/android/hardware/Camera.Parameters.html#getSupportedPictureSizes()。一旦您有了要搜索的方法名称,就会有大量示例代码。
由 1 回答。
您可以使用方向或忽略它,请参阅 http://developer.android.com/reference/android/hardware/Camera.Parameters.html
您只需在图像视图上调用 getWidth() 和 getHeight() 并调整位图大小以适合。
或者,您可以将图像视图本身的scaleType 设置为CENTER_INSIDE,然后将位图添加到其中(假设您已经有位图)。 http://developer.android.com/reference/android/widget/ImageView .ScaleType.html
You're looking for the getSupportedPictureSizes() method: http://developer.android.com/reference/android/hardware/Camera.Parameters.html#getSupportedPictureSizes(). And there's plenty of sample code out there once you have method names to search for.
Answered by 1.
You can either use the orientation or ignore it, see setRotation at http://developer.android.com/reference/android/hardware/Camera.Parameters.html
You can just call getWidth() and getHeight() on the image views and resize the bitmaps to fit.
Or you can set the scaleType for the image view itself to CENTER_INSIDE and just add the bitmap to it, assuming you already have a bitmap. http://developer.android.com/reference/android/widget/ImageView.ScaleType.html