【发布时间】:2012-08-28 16:36:38
【问题描述】:
我写了一个方法来改变相机拍摄的位图:
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中变量的信息是here。 索尼xperia的信息是here。
xperia 和其他设备工作正常。
编辑:
我在 LogCat 中得到了一些奇怪的日志,
当我拍照时,LogCat 会显示一些信息:
我从不使用视频...
为什么要播放视频??
【问题讨论】:
-
不要关注我必须缩放位图的原因,这是一个我不想说的复杂故事。让我们关注一下为什么S3不能在ImageView上显示图片,mHight和mWidth在S3和xperia中也是-1,但是为什么xperia可以正常工作,即使是另一个设备……,只是S3失败了
标签: android