Example usage for android.graphics.drawable PictureDrawable getIntrinsicHeight

List of usage examples for android.graphics.drawable PictureDrawable getIntrinsicHeight

Introduction

In this page you can find the example usage for android.graphics.drawable PictureDrawable getIntrinsicHeight.

Prototype

@Override
    public int getIntrinsicHeight() 

Source Link

Usage

From source file:Main.java

public static Bitmap pictureDrawable2Bitmap(PictureDrawable pictureDrawable) {
    Bitmap bitmap = Bitmap.createBitmap(pictureDrawable.getIntrinsicWidth(),
            pictureDrawable.getIntrinsicHeight(), Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    canvas.drawPicture(pictureDrawable.getPicture());
    return bitmap;
}

From source file:Main.java

public static Bitmap pictureDrawable2Bitmap(PictureDrawable pictureDrawable) {
    Bitmap bitmap = Bitmap.createBitmap(pictureDrawable.getIntrinsicWidth(),
            pictureDrawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    canvas.drawPicture(pictureDrawable.getPicture());
    return bitmap;
}

From source file:Main.java

private static Bitmap pictureDrawable2Bitmap(PictureDrawable pictureDrawable) {
    float intrinsicWidth = (float) pictureDrawable.getIntrinsicWidth();
    float intrinsicHeight = (float) pictureDrawable.getIntrinsicHeight();
    float f = 1.0f;
    if (intrinsicWidth < 600.0f || intrinsicHeight < 600.0f) {
        f = Math.min(600.0f / intrinsicWidth, 600.0f / intrinsicHeight);
        intrinsicWidth = (intrinsicWidth * f) + 0.5f;
        intrinsicHeight = (intrinsicHeight * f) + 0.5f;
    }/*from w  w  w .j  av a 2s  .  c  o m*/
    Bitmap createBitmap = Bitmap.createBitmap((int) intrinsicWidth, (int) intrinsicHeight, Config.ARGB_8888);
    Canvas canvas = new Canvas(createBitmap);
    Matrix matrix = new Matrix();
    matrix.preScale(f, f);
    canvas.concat(matrix);
    canvas.drawPicture(pictureDrawable.getPicture());
    return createBitmap;
}

From source file:com.ywesee.amiko.MainActivity.java

/**
 * Converts given picture to a bitmap//from  w w w. ja  v a2 s. c om
 * @param picture
 * @return
 */
private static Bitmap pictureDrawable2Bitmap(Picture picture) {
    PictureDrawable pictureDrawable = new PictureDrawable(picture);
    Bitmap bitmap = Bitmap.createBitmap(pictureDrawable.getIntrinsicWidth(),
            pictureDrawable.getIntrinsicHeight(), Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    canvas.drawPicture(pictureDrawable.getPicture());
    return bitmap;
}