Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.graphics.Bitmap;

public class Main {

    public static Bitmap getSingleColorBitmap(int picWidth, int picHeight, int color) {
        Bitmap bm1 = Bitmap.createBitmap(picWidth, picHeight, Bitmap.Config.ARGB_8888);

        int[] pix = new int[picWidth * picHeight];

        for (int y = 0; y < picHeight; y++)
            for (int x = 0; x < picWidth; x++) {
                int index = y * picWidth + x;
                //int r = ((pix[index] >> 16) & 0xff)|0xff;
                //int g = ((pix[index] >> 8) & 0xff)|0xff;
                //int b =( pix[index] & 0xff)|0xff;
                // pix[index] = 0xff000000 | (r << 16) | (g << 8) | b;
                pix[index] = color;

            }
        bm1.setPixels(pix, 0, picWidth, 0, 0, picWidth, picHeight);
        return bm1;
    }
}