【发布时间】:2011-09-24 22:04:49
【问题描述】:
我正在创建临时 Bitmap 以在其上绘制 Text,并且我想得到它 Pixels 以便我可以操纵这些像素(我不在屏幕上显示此图像)。
这是代码
Bitmap tempBitmap=Bitmap.createBitmap(200, 400, Bitmap.Config.ARGB_8888);//i've tested all Configs
Canvas tempCanvas=new Canvas(tempBitmap);
tempCanvas.drawColor(Color.WHITE);
tempCanvas.drawText("Hello", 0, 0, mPaint);//mPaint color set to Black
int[] pixels=new int[tempBitmap.getWidth() * tempBitmap.getHeight()];
tempBitmap.getPixels(pixels, 0, tempBitmap.getWidth(), 0, 0, tempBitmap.getWidth(), tempBitmap.getHeight());
但是当我打印所有像素时,它们都是 -1 值!为什么?
【问题讨论】: