Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Android create 3x3 2-color alternating image
/**
* A 3x3 2-color image.
* @param color1
* @param color2
* @return A 3x3 image alternating the two colors.
*/
public static Bitmap createTwoColorImage(int color1, int color2) {
Bitmap bitmap = Bitmap.createBitmap(3, 3, Bitmap.Config.ARGB_8888);
bitmap.setPixel(0, 0, color1);
bitmap.setPixel(2, 0, color1);
bitmap.setPixel(1, 1, color1);
bitmap.setPixel(0, 2, color1);
bitmap.setPixel(2, 2, color1);
bitmap.setPixel(1, 0, color2);
bitmap.setPixel(0, 1, color2);
bitmap.setPixel(2, 1, color2);
bitmap.setPixel(1, 2, color2);
return bitmap;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.