int inOffset = 0; int dataOffset = scanlineStride*y + x + data.getOffset(); for (int yy=y; yy<(y+h); yy++) { System.arraycopy(obj,inOffset,pixelData,dataOffset,w); dataOffset += scanlineStride; inOffset += w; } }
  public void setDataElements(int x, int y, Object obj, DataBuffer data)  {    int offset = scanlineStride*y + x + data.getOffset();        int transferType = getTransferType();    if (getTransferType() != data.getDataType())      {	throw new IllegalArgumentException("transfer type ("+					   getTransferType()+"), "+					   "does not match data "+					   "buffer type (" +					   data.getDataType() +					   ").");      }    try      {	switch (transferType)	  {	  case DataBuffer.TYPE_BYTE:	    {	      DataBufferByte out = (DataBufferByte) data;	      byte[] in = (byte[]) obj;	      out.getData()[offset] = in[0];	      return;	    }	  case DataBuffer.TYPE_USHORT:	    {	      DataBufferUShort out = (DataBufferUShort) data;	      short[] in = (short[]) obj;	      out.getData()[offset] = in[0];	      return;	    }	  case DataBuffer.TYPE_INT:	    {	      DataBufferInt out = (DataBufferInt) data;	      int[] in = (int[]) obj;	      out.getData()[offset] = in[0];	      return;	    }	    // FIXME: Fill in the other possible types.	  default:	    throw new InternalError();	  }      }    catch (ArrayIndexOutOfBoundsException aioobe)      {	String msg = "While writing data elements" +	  ", x="+x+", y="+y+	  ", width="+width+", height="+height+	  ", scanlineStride="+scanlineStride+	  ", offset="+offset+	  ", data.getSize()="+data.getSize()+	  ", data.getOffset()="+data.getOffset()+	  ": " +	  aioobe;	throw new ArrayIndexOutOfBoundsException(msg);      }    }