当前位置: 代码迷 >> Android >> 如何创建一个单色bitmap
  详细解决方案

如何创建一个单色bitmap

热度:250   发布时间:2016-05-01 22:27:15.0
怎么创建一个单色bitmap?
我想创建一个单色bitmap,然后再用这个bitmap创建一个BitmapDrawable...
那些函数的参数都不懂..谁有代码参考一下?
谢谢了~~纠结中.

------解决方案--------------------
全白
Java code
 int[] pix = new int[picw * pich];                       for (int y = 0; y < pich; y++)              for (int x = 0; x < picw; x++)                  {                  int index = y * picw + x;                  int r = ((pix[index] >> 16) & 0xff)|0xff;                  int g = ((pix[index] >> 8) & 0xff)|0xff;                  int b =( pix[index] & 0xff)|0xff;                  pix[index] = 0xff000000 | (r << 16) | (g << 8) | b;                                    }        bm1.setPixels(pix, 0, picw, 0, 0, picw, pich);        BitmapDrawable bmp11=new BitmapDrawable(bm1);
  相关解决方案