1 7 8 17 18 package java.awt.image; 19 20 25 26 public final class DataBufferByte extends DataBuffer 27 { 28 29 byte data[]; 30 31 32 byte bankdata[][]; 33 34 40 public DataBufferByte(int size) { 41 super(TYPE_BYTE,size); 42 data = new byte[size]; 43 bankdata = new byte[1][]; 44 bankdata[0] = data; 45 } 46 47 54 public DataBufferByte(int size, int numBanks) { 55 super(TYPE_BYTE, size, numBanks); 56 bankdata = new byte[numBanks][]; 57 for (int i= 0; i < numBanks; i++) { 58 bankdata[i] = new byte[size]; 59 } 60 data = bankdata[0]; 61 } 62 63 73 public DataBufferByte(byte dataArray[], int size) { 74 super(TYPE_BYTE,size); 75 data = dataArray; 76 bankdata = new byte[1][]; 77 bankdata[0] = data; 78 } 79 80 92 public DataBufferByte(byte dataArray[], int size, int offset){ 93 super(TYPE_BYTE,size,1,offset); 94 data = dataArray; 95 bankdata = new byte[1][]; 96 bankdata[0] = data; 97 } 98 99 108 public DataBufferByte(byte dataArray[][], int size) { 109 super(TYPE_BYTE,size,dataArray.length); 110 bankdata = (byte[][]) dataArray.clone(); 111 data = bankdata[0]; 112 } 113 114 128 public DataBufferByte(byte dataArray[][], int size, int offsets[]) { 129 super(TYPE_BYTE,size,dataArray.length,offsets); 130 bankdata = (byte[][]) dataArray.clone(); 131 data = bankdata[0]; 132 } 133 134 139 public byte[] getData() { 140 return data; 141 } 142 143 149 public byte[] getData(int bank) { 150 return bankdata[bank]; 151 } 152 153 157 public byte[][] getBankData() { 158 return (byte[][]) bankdata.clone(); 159 } 160 161 169 public int getElem(int i) { 170 return (int)(data[i+offset]) & 0xff; 171 } 172 173 182 public int getElem(int bank, int i) { 183 return (int)(bankdata[bank][i+offsets[bank]]) & 0xff; 184 } 185 186 195 public void setElem(int i, int val) { 196 data[i+offset] = (byte)val; 197 } 198 199 208 public void setElem(int bank, int i, int val) { 209 bankdata[bank][i+offsets[bank]] = (byte)val; 210 } 211 } 212 | Popular Tags |