Java Android drawBitmap绘制一种棋盘格图案
好吧,也许我错过了什么,但当我错过的时候Java Android drawBitmap绘制一种棋盘格图案,java,android,Java,Android,好吧,也许我错过了什么,但当我错过的时候 canvas.drawRGB(0x80, 0x80, 0x80); 我得到一个干净的预期灰色屏幕: 但是当我使用这个代码时 pixels = new int[800*480]; ... for(int x = 0; x < 800; x++) { for(int y = 0; y < 480; y++) { pixels[x+y*800] = 0xff808080;
canvas.drawRGB(0x80, 0x80, 0x80);
我得到一个干净的预期灰色屏幕:
但是当我使用这个代码时
pixels = new int[800*480];
...
for(int x = 0; x < 800; x++)
{
for(int y = 0; y < 480; y++)
{
pixels[x+y*800] = 0xff808080;
}
}
canvas.drawBitmap(pixels, 0, 800, 0, 0, 800, 480, false, null);
pixels=newint[800*480];
...
对于(int x=0;x<800;x++)
{
对于(int y=0;y<480;y++)
{
像素[x+y*800]=0xff808080;
}
}
drawBitmap(像素,0,800,0,0,800,480,false,null);
我的手机画的是这样的:(注意“棋盘格”图案;它不应该在那里)
模拟器中也会发生同样的情况,所以我想我做错了什么?这很奇怪。如果在drawBitmap中将hasAlpha设置为true会发生什么情况,因为您正在为数组中的每个像素设置alpha?嗯,修复了它。谢谢您!