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.
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?
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
精彩评论