Skip to content

Instantly share code, notes, and snippets.

@akdsouza
Forked from catehstn/AndroidOneColorImage.java
Created November 13, 2017 08:19
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 akdsouza/608eee1a83bc325fcae89009fdef5713 to your computer and use it in GitHub Desktop.
Save akdsouza/608eee1a83bc325fcae89009fdef5713 to your computer and use it in GitHub Desktop.
Android create one color image
/**
* A one color image.
* @param width
* @param height
* @param color
* @return A one color image with the given width and height.
*/
public static Bitmap createImage(int width, int height, int color) {
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint();
paint.setColor(color);
canvas.drawRect(0F, 0F, (float) width, (float) height, paint);
return bitmap;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment