Imagen de AppWidget con esquinas redondeadas

Por lo tanto, estoy creando dinámicamente una imagen dentro de mi aplicación animando varias Vistas que le muestro al usuario en el diseño principal de mi aplicación.

Actualmente estoy generando mi escena dentro de un RelativeLayout, tomando la imagen del diseño como un mapa de bits, luego guardando el mapa de bits en SD para que el appwidget acceda a través de uri.

Todo esto funciona muy bien, pero ... en un intento de crear esquinas redondeadas para la imagen del widget de aplicación, he intentado usar estos dos fragmentos que encontréaquí.

Mi problema:

es que este método genera un dibujo (cuyas esquinas redondeadas se ven perfectas si se muestran como dibujables) pero necesito exportar estas esquinas transparentes como un archivo de imagen. El método drawToBitmap en CustomView a continuación, genera una imagen de mapa de bits, pero las esquinas son completas y cuadradas.

/**
 * shows a bitmap as if it had rounded corners. based on :
 * http://rahulswackyworld.blogspot.co.il/2013/04/android-drawables-with-rounded_7.html
 */
public class RoundedCornersDrawable extends BitmapDrawable {

    private final BitmapShader bitmapShader;
    private final Paint p;
    private final RectF rect;
    private final float borderRadius;

    public RoundedCornersDrawable(final Resources resources, final Bitmap bitmap, final float     borderRadius) {
        super(resources, bitmap);
        bitmapShader = new BitmapShader(getBitmap(), Shader.TileMode.CLAMP,     Shader.TileMode.CLAMP);
        final Bitmap b = getBitmap();
        p = getPaint();
        p.setAntiAlias(true);
        p.setShader(bitmapShader);
        final int w = b.getWidth(), h = b.getHeight();
        rect = new RectF(0, 0, w, h);
        this.borderRadius = borderRadius < 0 ? 0.15f * Math.min(w, h) : borderRadius;
    }

    @Override
    public void draw(final Canvas canvas) {
        canvas.drawRoundRect(rect, borderRadius, borderRadius, p);
    }
}

y

public class CustomView extends ImageView {
    private FrameLayout mMainContainer;
    private boolean mIsDirty=false;

    // TODO for each change of views/content, set mIsDirty to true and call invalidate

    @Override
    protected void onDraw(final Canvas canvas) {
        if (mIsDirty) {
            mIsDirty = false;
            drawContent();
            return;
        }
        super.onDraw(canvas);
    }

    /**
     * draws the view's content to a bitmap. code based on :
     * http://nadavfima.com/android-snippet-inflate-a-layout-draw-to-a-bitmap/
     */
    public static Bitmap drawToBitmap(final View viewToDrawFrom, final int width, final int height) {
        // Create a new bitmap and a new canvas using that bitmap
        final Bitmap bmp = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
        final Canvas canvas = new Canvas(bmp);
        viewToDrawFrom.setDrawingCacheEnabled(true);
        // Supply measurements
        viewToDrawFrom.measure(MeasureSpec.makeMeasureSpec(canvas.getWidth(),     MeasureSpec.EXACTLY),
                MeasureSpec.makeMeasureSpec(canvas.getHeight(), MeasureSpec.EXACTLY));
        // Apply the measures so the layout would resize before drawing.
        viewToDrawFrom.layout(0, 0, viewToDrawFrom.getMeasuredWidth(),    viewToDrawFrom.getMeasuredHeight());
        // and now the bmp object will actually contain the requested layout
        canvas.drawBitmap(viewToDrawFrom.getDrawingCache(), 0, 0, new Paint());
        return bmp;
     }

    private void drawContent() {
        if (getMeasuredWidth() <= 0 || getMeasuredHeight() <= 0)
            return;
        final Bitmap bitmap = drawToBitmap(mMainContainer, getMeasuredWidth(), getMeasuredHeight());
        final RoundedCornersDrawable drawable = new RoundedCornersDrawable(getResources(),     bitmap, 15);
        setImageDrawable(drawable);
    }
}

Entiendo que un mapa de bits no contiene la información alfa que se necesita para tener esquinas redondeadas transparentes en la imagen, así que intenté guardar el archivo como PNG así;

RCD_test es un RoundedCornersDrawable

Bitmap bitmap = RCD_test.getBitmap();
bitmap.setHasAlpha(true);
OutputStream stream = new          
FileOutputStream(Environment.getExternalStorageDirectory().getPath()+"/test/screenshottest.png");
bitmap.compress(CompressFormat.PNG, 100, stream);
stream.close();

pero fue en vano. Todo este enfoque puede parecer complicado, pero esto es lo que se me ocurrió para abordar las limitaciones de RemoteViews de AppWidget.

Mi pregunta:

¿Cómo puedo tomar este RoundedCornersDrawable y exportarlo como un archivo PNG que representa correctamente sus hermosas esquinas transparentes?

¡Gracias de antemano por la ayuda, y estoy abierto a cualquier sugerencia sobre diferentes enfoques del problema en su conjunto!

Respuestas a la pregunta(2)

Su respuesta a la pregunta