天天看點

簡單記錄,圖檔的壓縮(縮略圖)

方法一:

  一句話搞定,

Bitmap newbitmap = ThumbnailUtils.extractThumbnail(bitmap, 128, 128);
           

方法二:

Bitmap bitmap = BitmapFactory.decodeResource(getResources(),
	 R.drawable.first);
	 //
	 int w = bitmap.getWidth();
	 int h = bitmap.getHeight();
	 float scalew = 640.0f/w;
	 float scaleh = 960.0f/h;
	
	 Matrix matrix = new Matrix();
	 matrix.postScale(scalew, scaleh);
	 Bitmap newBitmap =
	 Bitmap.createBitmap(bitmap,0,0,w,h,matrix,true);
           

隻是簡單方法應用,其他的一些參數應用未添加。