开发者

Android - dealing with images/camera - couple questions

开发者 https://www.devze.com 2023-03-19 12:38 出处:网络
I\'m dealing with resizing of images on Android - fun! Here is questions I have hopefully small :) I\'m using camera intent to take p开发者_如何学Cicture and save it on SD card.

I'm dealing with resizing of images on Android - fun! Here is questions I have hopefully small :) I'm using camera intent to take p开发者_如何学Cicture and save it on SD card.

  1. 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?

  2. Is resolution something that may change or it is fixed per device?

  3. Are all images saved in "landscape" format? I mean they always "wider" than "taller"?

  4. 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?

  5. 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?


  1. 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.

  2. Answered by 1.

  3. You can either use the orientation or ignore it, see setRotation at http://developer.android.com/reference/android/hardware/Camera.Parameters.html

  4. You can just call getWidth() and getHeight() on the image views and resize the bitmaps to fit.

  5. 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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号