您可以执行此操作以创建具有选定颜色的平方位图。
// Here you create the bound of your shape
Rect rect = new Rect(0, 0, 1, 1);
// You then create a Bitmap and get a canvas to draw into it
Bitmap image = Bitmap.createBitmap(rect.width(), rect.height(), Config.ARGB_8888);
Canvas canvas = new Canvas(image);
//You can get an int value representing an argb color by doing so. Put 1 as alpha by default
int color = Color.argb(alpha, red, green, blue);
//Paint holds information about how to draw shapes
Paint paint = new Paint();
paint.setColor(color);
// Then draw your shape
canvas.drawRect(rect, paint);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3399 次 |
最近记录: |