只顯示三成的圖像spa
private Bitmap createBitmap( Bitmap src) rest
{ get
boolean isPortrait = mContext.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;it
if( src == null ) io
{ map
return null; new
} return
int w = src.getWidth();
int h = src.getHeight();
Bitmap newb = Bitmap.createBitmap( w, h, Config.ARGB_8888 );
Canvas cv = new Canvas( newb );
if(isPortrait){
final Rect rect = new Rect(0, 0, w, (int)(h*0.3));
final Rect rect2 = new Rect(0, 0, w, (int)(h*0.3));
cv.drawBitmap(src, rect, rect2, null);
}else
{
final Rect rect = new Rect(0, 0, (int)(w*0.3), h);
final Rect rect2 = new Rect(0, 0, (int)(w*0.3), h);
cv.drawBitmap(src, rect, rect2, null);
}
cv.save( Canvas.ALL_SAVE_FLAG );
cv.restore();
return newb;
}