首先,我将数据存储到二维数组中,代码运行良好。代码如下所示,
for(int a = 0; a < bitmap1.getWidth(); a++){
// ------ This is X
for(int b = 0; b < bitmap1.getHeight()-1; b++){
// ---------- This is Y
intArray1[a][b] = Integer.toHexString(bitmap1.getPixel(a,b));
intArray2[a][b] = Integer.toHexString(bitmap2.getPixel(a,b));
intArray3[a][b] = Integer.toHexString(bitmap3.getPixel(a,b));
intArray4[a][b] = Integer.toHexString(bitmap4.getPixel(a,b));
intArray5[a][b] = Integer.toHexString(bitmap5.getPixel(a,b));
intArray6[a][b] = Integer.toHexString(bitmap6.getPixel(a,b));
intArray7[a][b] = Integer.toHexString(bitmap7.getPixel(a,b));
intArray8[a][b] = Integer.toHexString(bitmap8.getPixel(a,b));
}
}//end of Nested FOR
然后我nested for loops用来改变arrays上面的数据。但是,这只是1st array来自我的8 array. 有没有其他方法可以减少如此多的重复代码,而不是复制如下所示的相同代码并从1st arrayto转换8 array?
int [][] arrayOneZero = new int [array1.length][array1.length];
for(int a = 0; a < array1.length; a++){
for(int b = 0; b < array1.length-1; b++){
if(array1[a][b].equals("ffffffff")){
//This is White
arrayOneZero[a][b] = 1;
}else if(array1[a][b].equals("ff000000")){
//This is Black
arrayOneZero[a][b] = 0;
}else if(array1[a][b].equals("00000000")){
//THis is Black
arrayOneZero[a][b] = 0;
}
问题已编辑,但问题仍然存在。
湖上湖
相关分类