[問題] 關於Samsung S3的bitmap問題

看板AndroidDev作者 (Ivan)時間13年前 (2012/09/04 12:36), 編輯推噓1(101)
留言2則, 2人參與, 最新討論串1/1
最近寫了一個調整手機照相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

09/04 14:56, , 1F
先看rotatedBMP是不是null還有他的寬高吧
09/04 14:56, 1F

09/05 09:37, , 2F
看過了都正常耶~
09/05 09:37, 2F
文章代碼(AID): #1GHOKxYJ (AndroidDev)