1 7 8 17 18 package java.awt.image; 19 20 24 25 public final class DataBufferInt extends DataBuffer 26 { 27 28 int data[]; 29 30 31 int bankdata[][]; 32 33 39 public DataBufferInt(int size) { 40 super(TYPE_INT,size); 41 data = new int[size]; 42 bankdata = new int[1][]; 43 bankdata[0] = data; 44 } 45 46 53 public DataBufferInt(int size, int numBanks) { 54 super(TYPE_INT,size,numBanks); 55 bankdata = new int[numBanks][]; 56 for (int i= 0; i < numBanks; i++) { 57 bankdata[i] = new int[size]; 58 } 59 data = bankdata[0]; 60 } 61 62 72 public DataBufferInt(int dataArray[], int size) { 73 super(TYPE_INT,size); 74 data = dataArray; 75 bankdata = new int[1][]; 76 bankdata[0] = data; 77 } 78 79 90 public DataBufferInt(int dataArray[], int size, int offset) { 91 super(TYPE_INT,size,1,offset); 92 data = dataArray; 93 bankdata = new int[1][]; 94 bankdata[0] = data; 95 } 96 97 106 public DataBufferInt(int dataArray[][], int size) { 107 super(TYPE_INT, size, dataArray.length); 108 bankdata = (int [][]) dataArray.clone(); 109 data = bankdata[0]; 110 } 111 112 126 public DataBufferInt(int dataArray[][], int size, int offsets[]) { 127 super(TYPE_INT,size,dataArray.length,offsets); 128 bankdata = (int [][]) dataArray.clone(); 129 data = bankdata[0]; 130 } 131 132 137 public int[] getData() { 138 return data; 139 } 140 141 147 public int[] getData(int bank) { 148 return bankdata[bank]; 149 } 150 151 155 public int[][] getBankData() { 156 return (int [][]) bankdata.clone(); 157 } 158 159 167 public int getElem(int i) { 168 return data[i+offset]; 169 } 170 171 180 public int getElem(int bank, int i) { 181 return bankdata[bank][i+offsets[bank]]; 182 } 183 184 193 public void setElem(int i, int val) { 194 data[i+offset] = val; 195 } 196 197 206 public void setElem(int bank, int i, int val) { 207 bankdata[bank][i+offsets[bank]] = (int)val; 208 } 209 } 210 211 | Popular Tags |