切割drawable
public Drawable getWallpaper1(Drawable wallpaperDrawable, int cutHeight){
final float scale = getResources().getDisplayMetrics().density;
int temp_height = wallpaperDrawable.getIntrinsicHeight();
int temp_width = wallpaperDrawable.getIntrinsicWidth();
float height = Math.max(temp_height, temp_width)/scale;
float width = Math.min(temp_height, temp_width)/scale;
Bitmap bitmapWithReflection = Bitmap.createBitmap((int)width, (int)(height-cutHeight), Config.ARGB_8888);
Canvas canvas = new Canvas(bitmapWithReflection);
Paint paint = new Paint();
wallpaperDrawable.setBounds(0, -cutHeight, (int)width, (int)(height-cutHeight));
wallpaperDrawable.draw(canvas);
canvas.drawBitmap(bitmapWithReflection, 0, 0, paint);
return new BitmapDrawable(bitmapWithReflection);
}
浙公网安备 33010602011771号