1 7 8 package java.awt.image; 9 10 11 26 public class ShortLookupTable extends LookupTable { 27 28 31 32 short data[][]; 33 34 46 public ShortLookupTable(int offset, short data[][]) { 47 super(offset,data.length); 48 numComponents = data.length; 49 numEntries = data[0].length; 50 this.data = new short[numComponents][]; 51 for (int i=0; i < numComponents; i++) { 53 this.data[i] = data[i]; 54 } 55 } 56 57 67 public ShortLookupTable(int offset, short data[]) { 68 super(offset,data.length); 69 numComponents = 1; 70 numEntries = data.length; 71 this.data = new short[1][]; 72 this.data[0] = data; 73 } 74 75 81 public final short[][] getTable(){ 82 return data; 83 } 84 85 104 public int[] lookupPixel(int[] src, int[] dst){ 105 if (dst == null) { 106 dst = new int[src.length]; 108 } 109 110 if (numComponents == 1) { 111 for (int i=0; i < src.length; i++) { 113 int s = (src[i]&0xffff) - offset; 114 if (s < 0) { 115 throw new ArrayIndexOutOfBoundsException ("src["+i+ 116 "]-offset is "+ 117 "less than zero"); 118 } 119 dst[i] = (int) data[0][s]; 120 } 121 } 122 else { 123 for (int i=0; i < src.length; i++) { 124 int s = (src[i]&0xffff) - offset; 125 if (s < 0) { 126 throw new ArrayIndexOutOfBoundsException ("src["+i+ 127 "]-offset is "+ 128 "less than zero"); 129 } 130 dst[i] = (int) data[i][s]; 131 } 132 } 133 return dst; 134 } 135 136 155 public short[] lookupPixel(short[] src, short[] dst){ 156 if (dst == null) { 157 dst = new short[src.length]; 159 } 160 161 if (numComponents == 1) { 162 for (int i=0; i < src.length; i++) { 164 int s = (src[i]&0xffff) - offset; 165 if (s < 0) { 166 throw new ArrayIndexOutOfBoundsException ("src["+i+ 167 "]-offset is "+ 168 "less than zero"); 169 } 170 dst[i] = data[0][s]; 171 } 172 } 173 else { 174 for (int i=0; i < src.length; i++) { 175 int s = (src[i]&0xffff) - offset; 176 if (s < 0) { 177 throw new ArrayIndexOutOfBoundsException ("src["+i+ 178 "]-offset is "+ 179 "less than zero"); 180 } 181 dst[i] = data[i][s]; 182 } 183 } 184 return dst; 185 } 186 187 } 188 | Popular Tags |