日期:2014-05-20 浏览次数:20838 次
public void setPixels(int x, int y, int w, int h, int iArray[], DataBuffer data) { int x1 = x + w; int y1 = y + h; if (x < 0 || x >= width || w > width || x1 < 0 || x1 > width || y < 0 || y >= height || h > height || y1 < 0 || y1 > height) { throw new ArrayIndexOutOfBoundsException ("Coordinate out of bounds!"); } int lineOffset = y*scanlineStride + x; int srcOffset = 0; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { int value = data.getElem(lineOffset+j); for (int k=0; k < numBands; k++) { value &= ~bitMasks[k]; int srcValue = iArray[srcOffset++]; value |= ((srcValue << bitOffsets[k]) & bitMasks[k]); } data.setElem(lineOffset+j, value); } lineOffset += scanlineStride; } }