This file contains 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 image from an array of colors. | |
* @param width | |
* @param height | |
* @param colors | |
* @return image of given width and height filled with the given color array. | |
*/ | |
public static Bitmap createImage(int width, int height, int[] colors) { | |
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); | |
int x = 0; | |
int y = 0; | |
for (int color : colors) { | |
bitmap.setPixel(x, y, color); | |
x++; | |
if (x == width) { | |
x = 0; | |
y++; | |
} | |
} | |
return bitmap; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment