Skip to content

Instantly share code, notes, and snippets.

@catehstn
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save catehstn/b29ed68558f0ada568c6 to your computer and use it in GitHub Desktop.
Save catehstn/b29ed68558f0ada568c6 to your computer and use it in GitHub Desktop.
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