1package org.libreoffice.canvas;
3import android.graphics.Bitmap;
4import android.graphics.Canvas;
5import android.graphics.drawable.Drawable;
8 static Bitmap getBitmapForDrawable(Drawable drawable) {
9 drawable = drawable.mutate();
11 int width = !drawable.getBounds().isEmpty() ?
12 drawable.getBounds().width() : drawable.getIntrinsicWidth();
14 width = width <= 0 ? 1 : width;
16 int height = !drawable.getBounds().isEmpty() ?
17 drawable.getBounds().height() : drawable.getIntrinsicHeight();
19 height = height <= 0 ? 1 : height;
22 Canvas
canvas =
new Canvas(bitmap);
23 drawable.setBounds(0, 0,
canvas.getWidth(),
canvas.getHeight());