public void setSample(int x, int y, int b, int s, DataBuffer data) {  if ((x < 0) || (y < 0) || (x >= width) || (y >= height) || (b != 0)) { throw new ArrayIndexOutOfBoundsException("Coordinate out of bounds!"); } int bitnum = dataBitOffset + x * pixelBitStride; int index = y * scanlineStride + (bitnum / dataElementSize); int shift = dataElementSize - (bitnum & (dataElementSize - 1)) - pixelBitStride; int element = data.getElem(index); element &= ~(bitMask << shift); element |= (s & bitMask) << shift; data.setElem(index, element); }
public void setSample(int x, int y, int b, int s, DataBuffer data) { int bitpos = ((dataBitOffset + x * numberOfBits) % elemBits) / numberOfBits; int offset = getOffset(x, y);  s = s << bitOffsets[bitpos]; s = s & bitMasks[bitpos];  int sample = data.getElem(offset); sample |= s; data.setElem(offset, sample); }
	public void setSample(int x, int y, int b, int s, DataBuffer data) {		// 'b' must be 0		if ((x < 0) || (y < 0) || (x >= width) || (y >= height) || (b != 0)) {			throw new ArrayIndexOutOfBoundsException("Coordinate out of bounds!");		}		int bitnum = dataBitOffset + x * pixelBitStride;		int index = y * scanlineStride + (bitnum / dataElementSize);		int shift = dataElementSize - (bitnum & (dataElementSize - 1)) - pixelBitStride;		int element = data.getElem(index);		element &= ~(bitMask << shift);		element |= (s & bitMask) << shift;		data.setElem(index, element);	}