小编Min*_*hac的帖子

如何在Android中用颜色填充位图对象

我正在研究Android游戏,并且出现了一些问题,我想在位图对象上填充颜色,但我不能尝试bitmap.setPixel但我的图像是PNG格式(如圆形或不锐化,用透明色包围)和android不能getHeight()或getWidth(),即

ImageView i = new ImageView(mContext);
Bitmap bMap = BitmapFactory.decodeResource(this.mContext.getResources(), mImageIds[position]);

// for(int i1 = 0; i1 < bMap.getHeight();i1++) // for(int j = 0; j < bMap.getWidth(); j ++) // bMap.setPixel(i1, j, Color.RED); //can not set

i.setImageBitmap(bMap); i.setLayoutParams(new Gallery.LayoutParams(150, 100)); i.setScaleType(ImageView.ScaleType.FIT_XY); i.setBackgroundResource(mGalleryItemBackground); i.setBackgroundColor(Color.TRANSPARENT);
Run Code Online (Sandbox Code Playgroud)

android bitmap

16
推荐指数
2
解决办法
2万
查看次数

标签 统计

android ×1

bitmap ×1