我寫了從鏡頭改變位圖的方法:位圖問題
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失敗了 – user1531240