http://blog.sina.com.cn/s/blog_4b93170a0102e1m9.htmlhtml
//調用setCompoundDrawables時,必須調用Drawable.setBounds()方法,不然圖片不顯示 最主要一點,否則不顯示圖片,搞了半天post
/** * 從png文件獲得Bitmap * 而且將尺寸調整爲寬=w、高=h */ public static Bitmap getMyBitmap(String imageName, int w, int h){ String filePath = IMAGE_PATH + "/" + imageName + ".png"; Bitmap oldbmp = BitmapFactory.decodeFile(filePath); if(oldbmp!=null){ int width = oldbmp.getWidth(); int height = oldbmp.getHeight(); Matrix matrix = new Matrix(); float scaleWidth = ((float) w / width); float scaleHeight = ((float) h / height); matrix.postScale(scaleWidth, scaleHeight); Bitmap newbmp = Bitmap.createBitmap(oldbmp, 0, 0, width, height, matrix, true); return newbmp; } else{ return null; } }
調整分辨率spa
http://blog.sina.com.cn/s/blog_4607d856010125sl.html BitmapDrawable的使用轉換.net