我写了一个方法来改变相机拍摄的位图:
public Bitmap bitmapChange(Bitmap bm) {
/* get original image size */
int w = bm.getWidth();
int h = bm.getHeight();
/* check the image's orientation */
float scale = w / h;
if(scale < 1) {
/* if the orientation is portrait then scaled and show on the screen*/
float scaleWidth = (float) 90 / (float) w;
float scaleHeight = (float) 130 / (float) h;
Matrix mtx = new Matrix();
mtx.postScale(scaleWidth, scaleHeight);
Bitmap rotatedBMP = Bitmap.createBitmap(bm, 0, 0, w, h, mtx, true);
return rotatedBMP;
} else {
/* if the orientation is landscape then rotate 90 */
float scaleWidth = (float) 130 / (float) w;
float scaleHeight = (float) 90 / (float) h;
Matrix mtx = new Matrix();
mtx.postScale(scaleWidth, scaleHeight);
mtx.postRotate(90);
Bitmap rotatedBMP = Bitmap.createBitmap(bm, 0, 0, w, h, mtx, true);
return rotatedBMP;
}
}
它在其他 Android 设备(甚至 Galaxy Nexus)中运行良好,但在三星 Galaxy S3 中,缩放后的图像不会显示在屏幕上。
我试图标记该bitmapChange
方法,让它在屏幕上显示原始大小的位图,但 S3 在屏幕上也没有显示任何内容。
eclipse中的变量信息在这里。索尼 xperia 的信息在这里。
xperia 和其他设备工作正常。
编辑:
我在 LogCat 中有一些奇怪的日志,
当我拍照时,LogCat 会显示一些消息:
我从来不用视频...
为什么视频开始了??