Example usage for android.graphics Bitmap createBitmap

List of usage examples for android.graphics Bitmap createBitmap

Introduction

In this page you can find the example usage for android.graphics Bitmap createBitmap.

Prototype

public static @NonNull Bitmap createBitmap(@NonNull Picture source, int width, int height,
        @NonNull Config config) 

Source Link

Document

Creates a Bitmap from the given Picture source of recorded drawing commands.

Usage

From source file:Main.java

/**
 * Create a bitmap with some color./* www . j  ava 2s  .c o m*/
 *
 * @param config Bitmap config.
 * @return A bitmap.
 */
public static Bitmap createQuadColorBitmap(Bitmap.Config config) {
    return Bitmap.createBitmap(new int[] { Color.RED, Color.GREEN, Color.BLUE, Color.YELLOW }, 2, 2, config);
}

From source file:Main.java

public static Bitmap convert(float[] normals, int width, int height) {
    int[] pixels = new int[width * height];
    for (int i = 0; i < width * height; i++) {
        pixels[i] = Color.rgb((int) normals[4 * i + 0], (int) normals[4 * i + 1], (int) normals[4 * i + 2]);
    }/* www.j a  v  a  2  s. c  o m*/

    return Bitmap.createBitmap(pixels, width, height, Bitmap.Config.ARGB_8888);
}

From source file:Main.java

@Deprecated
public static Bitmap setAlpha(Bitmap source, int number) {
    int[] argb = new int[source.getWidth() * source.getHeight()];
    source.getPixels(argb, 0, source.getWidth(), 0, 0, source.getWidth(), source.getHeight());
    number = number * 255 / 100;/* ww w.j av a  2 s  . c o m*/
    for (int i = 0; i < argb.length; i++) {
        argb[i] = (number << 24) | (argb[i] & 0x00FFFFFF);
    }
    return Bitmap.createBitmap(argb, source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888);
}