Last active
August 29, 2015 14:17
-
-
Save catehstn/b29ed68558f0ada568c6 to your computer and use it in GitHub Desktop.
Android create 3x3 2-color alternating image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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