有人能建议一种从十六进制值创建小的纯色位图图像的方法吗?
你也可以使用Bitmap.eraseColor()为位图设置纯色。
示例:
import android.graphics.Bitmap;
...
Bitmap image = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
image.eraseColor(android.graphics.Color.GREEN);
我想我可能有答案。从技术上讲,我认为在Android上比在“pc”上要容易得多。上次我搜索创建位图(.bmp)的方法时,我只找到了一些Android函数和BitmapFactory
非安卓版本,但对我来说没有用。
请看这个网站:http://developer.android.com/reference/android/graphics/Bitmap.html
这一点可能适用于您:
static Bitmap createBitmap(int[] colors, int offset, int stride, int width, int height, Bitmap.Config config)
返回一个指定宽度和高度的不可变位图,每个像素值设置为颜色数组中的相应值。
Bitmap image = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas canvas=new Canvas (image);
int HEX=0xFF888888;
canvas.drawColor (HEX);
使用createBitmap()
方法。
这里有一个链接,可以向您展示如何使用:http://developer.android.com/reference/android/graphics/Bitmap.html