static Boolean[][] squares = new Boolean[32][32];
static BitmapFactory.Options opts = new BitmapFactory.Options();
public static Boolean[][] getFrame(int id){
opts.inPreferredConfig = Bitmap.Config.ALPHA_8;
opts.outHeight = 32;
opts.outWidth = 32;
Bitmap bmp = BitmapFactory.decodeResource(context.getResources(), R.raw.f11, opts);
for (int y = 0; y < 32; y++) {
for (int x = 0; x < 32; x++) {
int pixel = bmp.getPixel(x, y);
if(pixel == -1)
squares[x][y] = false;
else
squares[x][y] = true;
}
}
return squares;
}
ここで問題が発生しています。ビットマップ ファクトリがビットマップを正しくインポートしていないようです。元の外観は次のとおりで、 getPixel (および getPixels) から返されるものは次のとおりです。これは、宣言されたオプションの有無にかかわらず発生します。画像の 2 番目を 2 倍の解像度でインポートしているように見える理由を知りたいです。1 ビットと 4 ビットのビットマップを試し、1 ビットと 4 ビットの Bitmap.Config を宣言しました。ブール配列データを使用して、キャンバス上のグリッドに長方形を描画します。前もって感謝します。