1.创建纯白色位图

Bitmap bm1 = Bitmap.createBitmap(picw, pich, Bitmap.Config.ARGB_8888); 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; // pix[index] = 0xff000000; } bm1.setPixels(pix, 0, picw, 0, 0, picw, pich); BitmapDrawable bmp11=new BitmapDrawable(bm1); iv.setImageBitmap(bm1);

2.创建纯黑色位图

Bitmap bm1 = Bitmap.createBitmap(picw, pich, Bitmap.Config.ARGB_8888); 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; pix[index] = 0xff000000; } bm1.setPixels(pix, 0, picw, 0, 0, picw, pich); BitmapDrawable bmp11=new BitmapDrawable(bm1); iv.setImageBitmap(bm1);

更多相关文章

  1. Android绘制进阶之五:位图的处理
  2. Android(安卓)Bitmap相关
  3. android4.4 安装微信7.0.6版本底部显示黑色的问题
  4. android .9图讲解
  5. Android制作 9-Patch图片(可调整大小的位图)
  6. Android(安卓)SVG和Lottie库播放动画(Json)
  7. android 图片占用内存与什么有关
  8. JNI下使用AndroidBitmap_lockPixels修改位图为黑白照片
  9. android 中遇到的Ui问题

随机推荐

  1. Android刷Recovery
  2. INSTALL_PARSE_FAILED_MANIFEST_MALFORME
  3. Android简明开发教程二十四:总结及示例代
  4. 解开Android应用程序组件Activity的"sing
  5. Android画图之Matrix(二)
  6. 《Android(安卓)4游戏高级编程(第2版)》书
  7. Android中WebKit的应用
  8. Android模拟 HTTP multipart/form-data
  9. :Android模拟器的基本操作
  10. android:layout_weight