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 Bitmap createBitmap(int width, int height, @NonNull Config config) 

Source Link

Document

Returns a mutable bitmap with the specified width and height.

Usage

From source file:Main.java

public static Bitmap creatBitmapARGB8888(int width, int height) {
    return Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);

}

From source file:Main.java

public static Bitmap getEmptyBitmap() {

    Bitmap.Config conf = Bitmap.Config.ARGB_8888;
    return Bitmap.createBitmap(1, 1, conf);
}

From source file:Main.java

public static Bitmap convertToAlphaMask(Bitmap b) {
    Bitmap a = Bitmap.createBitmap(b.getWidth(), b.getHeight(), Bitmap.Config.ALPHA_8);
    Canvas c = new Canvas(a);
    c.drawBitmap(b, 0.0f, 0.0f, null);/*from   www  . j a  va  2 s  .  co m*/
    return a;
}

From source file:Main.java

public static Bitmap overlay(Bitmap b, int x, int y) {
    Bitmap empty = Bitmap.createBitmap(x, y, Bitmap.Config.ARGB_4444);
    Canvas cv = new Canvas(empty);
    cv.drawBitmap(b, 0, 0, null);/*from  ww  w  . j a  v  a  2 s.c o  m*/
    cv.save();
    return empty;
}

From source file:Main.java

public static Bitmap createBitmap(Bitmap bitmap, final String s) {
    bitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
    bitmap.eraseColor(Color.parseColor(s));
    return bitmap;
}

From source file:Main.java

public static Bitmap doInvert(Bitmap src) {
    Bitmap bmOut = Bitmap.createBitmap(src.getWidth(), src.getHeight(), src.getConfig());
    int A, R, G, B;
    int pixelColor;
    int w = src.getWidth();
    int h = src.getHeight();
    for (int y = 0; y < h; y++) {
        for (int x = 0; x < w; x++) {
            pixelColor = src.getPixel(x, y);
            A = Color.alpha(pixelColor);
            R = 255 - Color.red(pixelColor);
            G = 255 - Color.green(pixelColor);
            B = 255 - Color.blue(pixelColor);
            bmOut.setPixel(x, y, Color.argb(A, R, G, B));
        }/*from w  w w  . j av a 2s . co m*/
    }
    return bmOut;
}

From source file:Main.java

public static Bitmap scale(Bitmap b, float scale) {
    Bitmap res = Bitmap.createBitmap((int) (b.getWidth() * scale + .5f), (int) (b.getHeight() * scale + .5f),
            b.getConfig());// w ww .  j a  va 2s .com
    Canvas c = new Canvas(res);
    c.scale(scale, scale);
    c.drawBitmap(b, 0, 0, scalePaint);
    return res;
}

From source file:Main.java

private static Bitmap getScreenshot(View v) {
    Bitmap b = Bitmap.createBitmap(v.getWidth(), v.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas c = new Canvas(b);
    v.draw(c);/*www  . j a  v  a  2 s  . c om*/
    return b;
}

From source file:Main.java

public static Bitmap createBitmap(View v) {
    Bitmap bitmap = Bitmap.createBitmap(v.getWidth(), v.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    v.draw(canvas);/*from w  w  w.  j a v a 2  s .  c om*/
    return bitmap;
}

From source file:Main.java

public static Bitmap viewToBitmap(View view) {
    Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    view.draw(canvas);// w ww.  j  a  va 2s.c  o  m
    return bitmap;
}