作者ivanf10710 (Ivan)
看板AndroidDev
标题[问题] 关於Samsung S3的bitmap问题
时间Tue Sep 4 12:36:09 2012
最近写了一个调整手机照相bitmap重新调整大小的method
将照出来的像片调整到我 IamgeView 预设的大小然後 setImageBitmap 到 ImageView
大致上像这样:
首先开起相机照了一张照片以後
public Bitmap bitmapChange(Bitmap bm) {
//撷取原始大小
int w = bm.getWidth();
int h = bm.getHeight();
//判断使用者是横的照还是直的照
float scale = w / h;
if(scale < 1) {
//直的照就直接调整大小传回去
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 {
//横的照除了调整大小还要将它转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;
}
}
这个 method 在其他装置都 run 的很正常
相片也都乖乖的被我调整以後显示在 ImageView 上
唯独 Samsung S3 不管怎麽改都不会显示...
这是什麽巫术...
这个是S3在eclipse里面variables的截图
http://ppt.cc/PqIn
这个是Xperia的截图
http://ppt.cc/w03U
因为手边只有这两只,基本上是其他厂牌型号都可以 work
但是S3都没办法显示...
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 1.34.138.203
1F:推 lovelycateye:先看rotatedBMP是不是null还有他的宽高吧 09/04 14:56
2F:→ ivanf10710:看过了都正常耶~ 09/05 09:37