Code example for Canvas

Methods: scalesetBitmap

0
 
    private static void renderDrawableToBitmap( 
            Drawable d, Bitmap bitmap, int x, int y, int w, int h,
            float scale) {
        if (bitmap != null) {
            Canvas c = new Canvas(bitmap);
            c.scale(scale, scale);
            Rect oldBounds = d.copyBounds();
            d.setBounds(x, y, x + w, y + h);
            d.draw(c);
            d.setBounds(oldBounds); // Restore the bounds
            c.setBitmap(null);
        } 
    } 
 
} 
Experience pair programming with AI  Get Codota for Java