图片处理
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;
public class ImageUtils {
/**
* drawableToBitmap with white background
* @param drawable
* @return
*/
public static Bitmap drawableToBitmap(Drawable drawable) {
// 取 drawable 的长宽
int w = drawable.getIntrinsicWidth();
int h = drawable.getIntrinsicHeight();
// 取 drawable 的颜色格式
Bitmap.Config config = Bitmap.Config.ARGB_8888;
// 建立对应 bitmap
Bitmap bitmap = Bitmap.createBitmap(w, h, config);
// 建立对应 bitmap 的画布
Canvas canvas = new Canvas(bitmap);
// 白色底色 应对透明图
Paint paint = new Paint();
paint.setColor(Color.WHITE);
canvas.drawRect(0, 0, w, h, paint);
drawable.setBounds(0, 0, w, h);
// 把 drawable 内容画到