Java 类java.awt.image.DataBufferUShort 实例源码

项目:sumo    文件:Sentinel1GRD.java   
/**
* 
* @param x
* @param y
* @param width
* @param height
* @param band
* @return
*/
 public int readTileXY(int x, int y, int band) {
     Rectangle rect = new Rectangle(x, y, 1, 1);
     int val=0;

        if (y < 0||y>this.getHeight()||x<0||x>this.getWidth()) {
           val= 0;
        }else{
        TIFF tiff=(TIFF)getImage(band);
        try {
            BufferedImage bi=null;
            bi=tiff.read(0, rect);
            DataBufferUShort raster=(DataBufferUShort)bi.getRaster().getDataBuffer();
            short[] b=raster.getData();
            //short[] data=(short[])raster.getDataElements(0, 0, width,height, null);
            val=b[0];
        } catch (Exception ex) {
            logger.error(ex.getMessage(),ex);
        }
        }  

     return val;
 }
项目:sumo    文件:Alos.java   
/**
*
* @param x
* @param y
* @param width
* @param height
* @param band
* @return
*/
public int[] read(int x, int y,int w,int h, int band) {
 TIFF tiff=(TIFF)getImage(band);
    Rectangle rect = new Rectangle(x, y, w, h);
    rect = rect.intersection(tiff.getBounds());
    int data[]=null;

     try {
        BufferedImage bi=null;
        bi=tiff.read(0, rect);
        DataBufferUShort raster=(DataBufferUShort)bi.getRaster().getDataBuffer();
        short[] b=raster.getData();
        data=new int[b.length];
        for(int i=0;i<b.length;i++)
            data[i]=b[i];

     } catch (Exception ex) {
         logger.warn(ex.getMessage());
     }

    return data;
}
项目:sumo    文件:AlosGeoTiff.java   
/**
*
* @param x
* @param y
* @param width
* @param height
* @param band
* @return
*/
public int[] read(int x, int y,int w,int h, int band) {
    Rectangle rect = new Rectangle(x, y, w, h);
    rect = rect.intersection(getImage(band).getBounds());
    int data[]=null;

     TIFF tiff=getImage(band);
     try {
        BufferedImage bi=null;
        bi=tiff.read(0, rect);
        DataBufferUShort raster=(DataBufferUShort)bi.getRaster().getDataBuffer();
        short[] b=raster.getData();
        data=new int[b.length];
        for(int i=0;i<b.length;i++)
            data[i]=b[i];

     } catch (Exception ex) {
         logger.warn(ex.getMessage());
     }finally{
     }

    return data;
}
项目:OpenJSharp    文件:Buffers.java   
/**
  * Create a data buffer of a particular type.
  *
  * @param dataType the desired data type of the buffer.
  * @param size the size of the data buffer bank
  * @param numBanks the number of banks the buffer should have
  */
 public static DataBuffer createBuffer(int dataType, int size, int numBanks)
 {
   switch (dataType)
     {
     case DataBuffer.TYPE_BYTE:
return new DataBufferByte(size, numBanks);
     case DataBuffer.TYPE_SHORT:
return new DataBufferShort(size, numBanks);
     case DataBuffer.TYPE_USHORT:
return new DataBufferUShort(size, numBanks);
     case DataBuffer.TYPE_INT:
return new DataBufferInt(size, numBanks);
     case DataBuffer.TYPE_FLOAT:
return new DataBufferFloat(size, numBanks);
     case DataBuffer.TYPE_DOUBLE:
return new DataBufferDouble(size, numBanks);
     default:
throw new UnsupportedOperationException();
     }
 }
项目:OpenJSharp    文件:Buffers.java   
/**
  * Create a data buffer of a particular type.
  *
  * @param dataType the desired data type of the buffer
  * @param data an array containing the data
  * @param size the size of the data buffer bank
  */
 public static DataBuffer createBufferFromData(int dataType, Object data,
                    int size)
 {
   switch (dataType)
     {
     case DataBuffer.TYPE_BYTE:
return new DataBufferByte((byte[]) data, size);
     case DataBuffer.TYPE_SHORT:
return new DataBufferShort((short[]) data, size);
     case DataBuffer.TYPE_USHORT:
return new DataBufferUShort((short[]) data, size);
     case DataBuffer.TYPE_INT:
return new DataBufferInt((int[]) data, size);
     case DataBuffer.TYPE_FLOAT:
return new DataBufferFloat((float[]) data, size);
     case DataBuffer.TYPE_DOUBLE:
return new DataBufferDouble((double[]) data, size);
     default:
throw new UnsupportedOperationException();
     }
 }
项目:javify    文件:Buffers.java   
/**
 * Create a data buffer of a particular type.
 *
 * @param dataType the desired data type of the buffer.
 * @param size the size of the data buffer bank
 * @param numBanks the number of banks the buffer should have
 */
public static DataBuffer createBuffer(int dataType, int size, int numBanks)
{
  switch (dataType)
    {
    case DataBuffer.TYPE_BYTE:
      return new DataBufferByte(size, numBanks);
    case DataBuffer.TYPE_SHORT:
      return new DataBufferShort(size, numBanks);
    case DataBuffer.TYPE_USHORT:
      return new DataBufferUShort(size, numBanks);
    case DataBuffer.TYPE_INT:
      return new DataBufferInt(size, numBanks);
    case DataBuffer.TYPE_FLOAT:
      return new DataBufferFloat(size, numBanks);
    case DataBuffer.TYPE_DOUBLE:
      return new DataBufferDouble(size, numBanks);
    default:
      throw new UnsupportedOperationException();
    }
}
项目:javify    文件:Buffers.java   
/**
 * Create a data buffer of a particular type.
 *
 * @param dataType the desired data type of the buffer
 * @param data an array containing the data
 * @param size the size of the data buffer bank
 */
public static DataBuffer createBufferFromData(int dataType, Object data,
                                              int size)
{
  switch (dataType)
    {
    case DataBuffer.TYPE_BYTE:
      return new DataBufferByte((byte[]) data, size);
    case DataBuffer.TYPE_SHORT:
      return new DataBufferShort((short[]) data, size);
    case DataBuffer.TYPE_USHORT:
      return new DataBufferUShort((short[]) data, size);
    case DataBuffer.TYPE_INT:
      return new DataBufferInt((int[]) data, size);
    case DataBuffer.TYPE_FLOAT:
      return new DataBufferFloat((float[]) data, size);
    case DataBuffer.TYPE_DOUBLE:
      return new DataBufferDouble((double[]) data, size);
    default:
      throw new UnsupportedOperationException();
    }
}
项目:jvm-stm    文件:Buffers.java   
/**
  * Create a data buffer of a particular type.
  *
  * @param dataType the desired data type of the buffer.
  * @param size the size of the data buffer bank
  * @param numBanks the number of banks the buffer should have
  */
 public static DataBuffer createBuffer(int dataType, int size, int numBanks)
 {
   switch (dataType)
     {
     case DataBuffer.TYPE_BYTE:
return new DataBufferByte(size, numBanks);
     case DataBuffer.TYPE_SHORT:
return new DataBufferShort(size, numBanks);
     case DataBuffer.TYPE_USHORT:
return new DataBufferUShort(size, numBanks);
     case DataBuffer.TYPE_INT:
return new DataBufferInt(size, numBanks);
     case DataBuffer.TYPE_FLOAT:
return new DataBufferFloat(size, numBanks);
     case DataBuffer.TYPE_DOUBLE:
return new DataBufferDouble(size, numBanks);
     default:
throw new UnsupportedOperationException();
     }
 }
项目:jvm-stm    文件:Buffers.java   
/**
  * Create a data buffer of a particular type.
  *
  * @param dataType the desired data type of the buffer
  * @param data an array containing the data
  * @param size the size of the data buffer bank
  */
 public static DataBuffer createBufferFromData(int dataType, Object data,
                    int size)
 {
   switch (dataType)
     {
     case DataBuffer.TYPE_BYTE:
return new DataBufferByte((byte[]) data, size);
     case DataBuffer.TYPE_SHORT:
return new DataBufferShort((short[]) data, size);
     case DataBuffer.TYPE_USHORT:
return new DataBufferUShort((short[]) data, size);
     case DataBuffer.TYPE_INT:
return new DataBufferInt((int[]) data, size);
     case DataBuffer.TYPE_FLOAT:
return new DataBufferFloat((float[]) data, size);
     case DataBuffer.TYPE_DOUBLE:
return new DataBufferDouble((double[]) data, size);
     default:
throw new UnsupportedOperationException();
     }
 }
项目:RipplePower    文件:GraphicsUtils.java   
public static Object getData(final DataBuffer db) {
    if (db instanceof DataBufferByte) {
        return ((DataBufferByte) db).getData();
    } else if (db instanceof DataBufferUShort) {
        return ((DataBufferUShort) db).getData();
    } else if (db instanceof DataBufferShort) {
        return ((DataBufferShort) db).getData();
    } else if (db instanceof DataBufferInt) {
        return ((DataBufferInt) db).getData();
    } else if (db instanceof DataBufferFloat) {
        return ((DataBufferFloat) db).getData();
    } else if (db instanceof DataBufferDouble) {
        return ((DataBufferDouble) db).getData();
    } else {
        throw new RuntimeException("Not found DataBuffer class !");
    }
}
项目:cn1    文件:AwtImageBackdoorAccessorImpl.java   
@Override
public Object getData(DataBuffer db) {
    if (db instanceof DataBufferByte){
        return ((DataBufferByte)db).getData();
    } else if (db instanceof DataBufferUShort){
        return ((DataBufferUShort)db).getData();
    } else if (db instanceof DataBufferShort){
        return ((DataBufferShort)db).getData();
    } else if (db instanceof DataBufferInt){
        return ((DataBufferInt)db).getData();
    } else if (db instanceof DataBufferFloat){
        return ((DataBufferFloat)db).getData();
    } else if (db instanceof DataBufferDouble){
        return ((DataBufferDouble)db).getData();
    } else {
        // awt.235=Wrong Data Buffer type : {0}
        throw new IllegalArgumentException(Messages.getString("awt.235", //$NON-NLS-1$
                db.getClass()));
    }
}
项目:cn1    文件:SinglePixelPackedSampleModelTest.java   
@Override
protected void setUp() throws Exception {
    super.setUp();
    dbb1 = new DataBufferByte(w * h);
    dbb2 = new DataBufferByte(scanlineStride * (h - 1) + w);
    dbu1 = new DataBufferUShort(w * h);
    dbu2 = new DataBufferUShort(scanlineStride * (h - 1) + w);
    dbi1 = new DataBufferInt(w * h);
    dbi2 = new DataBufferInt(scanlineStride * (h - 1) + w);
    sppsmb1 = new SinglePixelPackedSampleModel(DataBuffer.TYPE_BYTE, w, h, bitMaskB);
    sppsmb2 = new SinglePixelPackedSampleModel(DataBuffer.TYPE_BYTE, w, h, scanlineStride, bitMaskB);
    sppsmu1 = new SinglePixelPackedSampleModel(DataBuffer.TYPE_USHORT, w, h, bitMaskUS);
    sppsmu2 = new SinglePixelPackedSampleModel(DataBuffer.TYPE_USHORT, w, h, scanlineStride, bitMaskUS);
    sppsmi1 = new SinglePixelPackedSampleModel(DataBuffer.TYPE_INT, w, h, bitMaskI);
    sppsmi2 = new SinglePixelPackedSampleModel(DataBuffer.TYPE_INT, w, h, scanlineStride, bitMaskI);
    initTestData();
}
项目:cn1    文件:DataBufferUShortTest.java   
@Override
protected void setUp() throws Exception {
    super.setUp();
    short dataArrays[][] = new short[numBanks][];
    for(int i = 0; i < numBanks; i++){
        dataArrays[i] = new short[arraySize];
    }

    short dataArray[] = new short[arraySize];
    int offsets[] = new int[numBanks];
    for(int i = 0; i < numBanks; i++){
        offsets[i] = i;
    }

    db1 = new DataBufferUShort(dataArrays, size);
    db2 = new DataBufferUShort(dataArrays, size, offsets);
    db3 = new DataBufferUShort(dataArray, size);
    db4 = new DataBufferUShort(dataArray, size, numBanks);
    db5 = new DataBufferUShort(size);
    db6 = new DataBufferUShort(size, numBanks);
}
项目:JamVM-PH    文件:Buffers.java   
/**
  * Create a data buffer of a particular type.
  *
  * @param dataType the desired data type of the buffer.
  * @param size the size of the data buffer bank
  * @param numBanks the number of banks the buffer should have
  */
 public static DataBuffer createBuffer(int dataType, int size, int numBanks)
 {
   switch (dataType)
     {
     case DataBuffer.TYPE_BYTE:
return new DataBufferByte(size, numBanks);
     case DataBuffer.TYPE_SHORT:
return new DataBufferShort(size, numBanks);
     case DataBuffer.TYPE_USHORT:
return new DataBufferUShort(size, numBanks);
     case DataBuffer.TYPE_INT:
return new DataBufferInt(size, numBanks);
     case DataBuffer.TYPE_FLOAT:
return new DataBufferFloat(size, numBanks);
     case DataBuffer.TYPE_DOUBLE:
return new DataBufferDouble(size, numBanks);
     default:
throw new UnsupportedOperationException();
     }
 }
项目:JamVM-PH    文件:Buffers.java   
/**
  * Create a data buffer of a particular type.
  *
  * @param dataType the desired data type of the buffer
  * @param data an array containing the data
  * @param size the size of the data buffer bank
  */
 public static DataBuffer createBufferFromData(int dataType, Object data,
                    int size)
 {
   switch (dataType)
     {
     case DataBuffer.TYPE_BYTE:
return new DataBufferByte((byte[]) data, size);
     case DataBuffer.TYPE_SHORT:
return new DataBufferShort((short[]) data, size);
     case DataBuffer.TYPE_USHORT:
return new DataBufferUShort((short[]) data, size);
     case DataBuffer.TYPE_INT:
return new DataBufferInt((int[]) data, size);
     case DataBuffer.TYPE_FLOAT:
return new DataBufferFloat((float[]) data, size);
     case DataBuffer.TYPE_DOUBLE:
return new DataBufferDouble((double[]) data, size);
     default:
throw new UnsupportedOperationException();
     }
 }
项目:classpath    文件:Buffers.java   
/**
 * Create a data buffer of a particular type.
 *
 * @param dataType the desired data type of the buffer.
 * @param size the size of the data buffer bank
 * @param numBanks the number of banks the buffer should have
 */
public static DataBuffer createBuffer(int dataType, int size, int numBanks)
{
  switch (dataType)
    {
    case DataBuffer.TYPE_BYTE:
      return new DataBufferByte(size, numBanks);
    case DataBuffer.TYPE_SHORT:
      return new DataBufferShort(size, numBanks);
    case DataBuffer.TYPE_USHORT:
      return new DataBufferUShort(size, numBanks);
    case DataBuffer.TYPE_INT:
      return new DataBufferInt(size, numBanks);
    case DataBuffer.TYPE_FLOAT:
      return new DataBufferFloat(size, numBanks);
    case DataBuffer.TYPE_DOUBLE:
      return new DataBufferDouble(size, numBanks);
    default:
      throw new UnsupportedOperationException();
    }
}
项目:classpath    文件:Buffers.java   
/**
 * Create a data buffer of a particular type.
 *
 * @param dataType the desired data type of the buffer
 * @param data an array containing the data
 * @param size the size of the data buffer bank
 */
public static DataBuffer createBufferFromData(int dataType, Object data,
                                              int size)
{
  switch (dataType)
    {
    case DataBuffer.TYPE_BYTE:
      return new DataBufferByte((byte[]) data, size);
    case DataBuffer.TYPE_SHORT:
      return new DataBufferShort((short[]) data, size);
    case DataBuffer.TYPE_USHORT:
      return new DataBufferUShort((short[]) data, size);
    case DataBuffer.TYPE_INT:
      return new DataBufferInt((int[]) data, size);
    case DataBuffer.TYPE_FLOAT:
      return new DataBufferFloat((float[]) data, size);
    case DataBuffer.TYPE_DOUBLE:
      return new DataBufferDouble((double[]) data, size);
    default:
      throw new UnsupportedOperationException();
    }
}
项目:freeVM    文件:AwtImageBackdoorAccessorImpl.java   
@Override
public Object getData(DataBuffer db) {
    if (db instanceof DataBufferByte){
        return ((DataBufferByte)db).getData();
    } else if (db instanceof DataBufferUShort){
        return ((DataBufferUShort)db).getData();
    } else if (db instanceof DataBufferShort){
        return ((DataBufferShort)db).getData();
    } else if (db instanceof DataBufferInt){
        return ((DataBufferInt)db).getData();
    } else if (db instanceof DataBufferFloat){
        return ((DataBufferFloat)db).getData();
    } else if (db instanceof DataBufferDouble){
        return ((DataBufferDouble)db).getData();
    } else {
        // awt.235=Wrong Data Buffer type : {0}
        throw new IllegalArgumentException(Messages.getString("awt.235", //$NON-NLS-1$
                db.getClass()));
    }
}
项目:freeVM    文件:SinglePixelPackedSampleModelTest.java   
@Override
protected void setUp() throws Exception {
    super.setUp();
    dbb1 = new DataBufferByte(w * h);
    dbb2 = new DataBufferByte(scanlineStride * (h - 1) + w);
    dbu1 = new DataBufferUShort(w * h);
    dbu2 = new DataBufferUShort(scanlineStride * (h - 1) + w);
    dbi1 = new DataBufferInt(w * h);
    dbi2 = new DataBufferInt(scanlineStride * (h - 1) + w);
    sppsmb1 = new SinglePixelPackedSampleModel(DataBuffer.TYPE_BYTE, w, h, bitMaskB);
    sppsmb2 = new SinglePixelPackedSampleModel(DataBuffer.TYPE_BYTE, w, h, scanlineStride, bitMaskB);
    sppsmu1 = new SinglePixelPackedSampleModel(DataBuffer.TYPE_USHORT, w, h, bitMaskUS);
    sppsmu2 = new SinglePixelPackedSampleModel(DataBuffer.TYPE_USHORT, w, h, scanlineStride, bitMaskUS);
    sppsmi1 = new SinglePixelPackedSampleModel(DataBuffer.TYPE_INT, w, h, bitMaskI);
    sppsmi2 = new SinglePixelPackedSampleModel(DataBuffer.TYPE_INT, w, h, scanlineStride, bitMaskI);
    initTestData();
}
项目:freeVM    文件:DataBufferUShortTest.java   
@Override
protected void setUp() throws Exception {
    super.setUp();
    short dataArrays[][] = new short[numBanks][];
    for(int i = 0; i < numBanks; i++){
        dataArrays[i] = new short[arraySize];
    }

    short dataArray[] = new short[arraySize];
    int offsets[] = new int[numBanks];
    for(int i = 0; i < numBanks; i++){
        offsets[i] = i;
    }

    db1 = new DataBufferUShort(dataArrays, size);
    db2 = new DataBufferUShort(dataArrays, size, offsets);
    db3 = new DataBufferUShort(dataArray, size);
    db4 = new DataBufferUShort(dataArray, size, numBanks);
    db5 = new DataBufferUShort(size);
    db6 = new DataBufferUShort(size, numBanks);
}
项目:freeVM    文件:AwtImageBackdoorAccessorImpl.java   
@Override
public Object getData(DataBuffer db) {
    if (db instanceof DataBufferByte){
        return ((DataBufferByte)db).getData();
    } else if (db instanceof DataBufferUShort){
        return ((DataBufferUShort)db).getData();
    } else if (db instanceof DataBufferShort){
        return ((DataBufferShort)db).getData();
    } else if (db instanceof DataBufferInt){
        return ((DataBufferInt)db).getData();
    } else if (db instanceof DataBufferFloat){
        return ((DataBufferFloat)db).getData();
    } else if (db instanceof DataBufferDouble){
        return ((DataBufferDouble)db).getData();
    } else {
        // awt.235=Wrong Data Buffer type : {0}
        throw new IllegalArgumentException(Messages.getString("awt.235", //$NON-NLS-1$
                db.getClass()));
    }
}
项目:freeVM    文件:DataBufferUShortTest.java   
@Override
protected void setUp() throws Exception {
    super.setUp();
    short dataArrays[][] = new short[numBanks][];
    for(int i = 0; i < numBanks; i++){
        dataArrays[i] = new short[arraySize];
    }

    short dataArray[] = new short[arraySize];
    int offsets[] = new int[numBanks];
    for(int i = 0; i < numBanks; i++){
        offsets[i] = i;
    }

    db1 = new DataBufferUShort(dataArrays, size);
    db2 = new DataBufferUShort(dataArrays, size, offsets);
    db3 = new DataBufferUShort(dataArray, size);
    db4 = new DataBufferUShort(dataArray, size, numBanks);
    db5 = new DataBufferUShort(size);
    db6 = new DataBufferUShort(size, numBanks);
}
项目:scifio    文件:AWTImageTools.java   
/** Extracts pixel data as arrays of unsigned shorts, one per channel. */
public static short[][] getShorts(final WritableRaster r, final int x,
    final int y, final int w, final int h)
{
    if (canUseBankDataDirectly(r, DataBuffer.TYPE_USHORT,
        DataBufferUShort.class) &&
        x == 0 && y == 0 && w == r.getWidth() && h == r.getHeight())
    {
        return ((DataBufferUShort) r.getDataBuffer()).getBankData();
    }
    final int c = r.getNumBands();
    final short[][] samples = new short[c][w * h];
    final int[] buf = new int[w * h];
    for (int i = 0; i < c; i++) {
        r.getSamples(x, y, w, h, i, buf);
        for (int j = 0; j < buf.length; j++)
            samples[i][j] = (short) buf[j];
    }
    return samples;
}
项目:WorldPainter    文件:ObjectUtils.java   
public static DataBuffer clone(DataBuffer dataBuffer) {
    if (dataBuffer instanceof DataBufferByte) {
        return clone((DataBufferByte) dataBuffer);
    } else if (dataBuffer instanceof DataBufferDouble) {
        return clone((DataBufferDouble) dataBuffer);
    } else if (dataBuffer instanceof DataBufferFloat) {
        return clone((DataBufferFloat) dataBuffer);
    } else if (dataBuffer instanceof DataBufferInt) {
        return clone((DataBufferInt) dataBuffer);
    } else if (dataBuffer instanceof DataBufferShort) {
        return clone((DataBufferShort) dataBuffer);
    } else if (dataBuffer instanceof DataBufferUShort) {
        return clone((DataBufferUShort) dataBuffer);
    } else {
        throw new UnsupportedOperationException("Don't know how to clone " + dataBuffer.getClass().getName());
    }
}
项目:incubator-netbeans    文件:ImageBuilder.java   
@Override
public DataBuffer convert(FieldAccessor fa, Instance instance) throws FieldAccessor.InvalidFieldException {
    int size = fa.getInt(instance, "size");                        // NOI18N
    int[] offsets = fa.getIntArray(instance, "offsets", false);      // NOI18N
    short[][] bankdata = fa.getShortArray2(instance, "bankdata", false); // NOI18N
    return new DataBufferUShort(bankdata, size, offsets);
}
项目:sumo    文件:Sentinel1.java   
/**
*
* @param x
* @param y
* @param width
* @param height
* @param band
* @return
*/
public int[] read(int x, int y,int w,int h, int band) {
    Rectangle rect = new Rectangle(x, y, w, h);
    rect = rect.intersection(getImage(band).getBounds());
    int data[]=null;

     TIFF tiff=(TIFF)getImage(band);
     BufferedImage bi=null;
     try {
        bi=tiff.read(0, rect);
     } catch (Exception ex) {
        try {
            //try again
            Thread.sleep(100);
    bi=tiff.read(0, rect);
} catch (IOException | InterruptedException e) {
    logger.warn(ex.getMessage());
}
     }finally{
     }
     if(bi!=null){
DataBufferUShort raster=(DataBufferUShort)bi.getRaster().getDataBuffer();
short[] b=raster.getData();
data=new int[b.length];
    for(int i=0;i<b.length;i++)
        data[i]=b[i];
     }
    return data;
}
项目:OpenJSharp    文件:ShortBandedRaster.java   
/**
 * Constructs a ShortBandedRaster with the given SampleModel,
 * DataBuffer, and parent.  DataBuffer must be a DataBufferUShort and
 * SampleModel must be of type BandedSampleModel.
 * When translated into the base Raster's
 * coordinate system, aRegion must be contained by the base Raster.
 * Origin is the coordinate in the new Raster's coordinate system of
 * the origin of the base Raster.  (The base Raster is the Raster's
 * ancestor which has no parent.)
 *
 * Note that this constructor should generally be called by other
 * constructors or create methods, it should not be used directly.
 * @param sampleModel     The SampleModel that specifies the layout.
 * @param dataBuffer      The DataBufferUShort that contains the image data.
 * @param aRegion         The Rectangle that specifies the image area.
 * @param origin          The Point that specifies the origin.
 * @param parent          The parent (if any) of this raster.
 */
public ShortBandedRaster(SampleModel sampleModel,
                            DataBuffer dataBuffer,
                            Rectangle aRegion,
                            Point origin,
                            ShortBandedRaster parent) {

    super(sampleModel, dataBuffer, aRegion, origin, parent);
    this.maxX = minX + width;
    this.maxY = minY + height;
    if (!(dataBuffer instanceof DataBufferUShort)) {
       throw new RasterFormatException("ShortBandedRaster must have " +
            "ushort DataBuffers");
    }
    DataBufferUShort dbus = (DataBufferUShort)dataBuffer;

    if (sampleModel instanceof BandedSampleModel) {
        BandedSampleModel bsm = (BandedSampleModel)sampleModel;
        this.scanlineStride = bsm.getScanlineStride();
        int bankIndices[] = bsm.getBankIndices();
        int bandOffsets[] = bsm.getBandOffsets();
        int dOffsets[] = dbus.getOffsets();
        dataOffsets = new int[bankIndices.length];
        data = new short[bankIndices.length][];
        int xOffset = aRegion.x - origin.x;
        int yOffset = aRegion.y - origin.y;
        for (int i = 0; i < bankIndices.length; i++) {
           data[i] = stealData(dbus, bankIndices[i]);
           dataOffsets[i] = dOffsets[bankIndices[i]] +
               xOffset + yOffset*scanlineStride + bandOffsets[i];
        }
    } else {
        throw new RasterFormatException("ShortBandedRasters must have "+
            "BandedSampleModels");
    }
    verify();
}
项目:jdk8u-jdk    文件:ShortBandedRaster.java   
/**
 * Constructs a ShortBandedRaster with the given SampleModel,
 * DataBuffer, and parent.  DataBuffer must be a DataBufferUShort and
 * SampleModel must be of type BandedSampleModel.
 * When translated into the base Raster's
 * coordinate system, aRegion must be contained by the base Raster.
 * Origin is the coordinate in the new Raster's coordinate system of
 * the origin of the base Raster.  (The base Raster is the Raster's
 * ancestor which has no parent.)
 *
 * Note that this constructor should generally be called by other
 * constructors or create methods, it should not be used directly.
 * @param sampleModel     The SampleModel that specifies the layout.
 * @param dataBuffer      The DataBufferUShort that contains the image data.
 * @param aRegion         The Rectangle that specifies the image area.
 * @param origin          The Point that specifies the origin.
 * @param parent          The parent (if any) of this raster.
 */
public ShortBandedRaster(SampleModel sampleModel,
                            DataBuffer dataBuffer,
                            Rectangle aRegion,
                            Point origin,
                            ShortBandedRaster parent) {

    super(sampleModel, dataBuffer, aRegion, origin, parent);
    this.maxX = minX + width;
    this.maxY = minY + height;
    if (!(dataBuffer instanceof DataBufferUShort)) {
       throw new RasterFormatException("ShortBandedRaster must have " +
            "ushort DataBuffers");
    }
    DataBufferUShort dbus = (DataBufferUShort)dataBuffer;

    if (sampleModel instanceof BandedSampleModel) {
        BandedSampleModel bsm = (BandedSampleModel)sampleModel;
        this.scanlineStride = bsm.getScanlineStride();
        int bankIndices[] = bsm.getBankIndices();
        int bandOffsets[] = bsm.getBandOffsets();
        int dOffsets[] = dbus.getOffsets();
        dataOffsets = new int[bankIndices.length];
        data = new short[bankIndices.length][];
        int xOffset = aRegion.x - origin.x;
        int yOffset = aRegion.y - origin.y;
        for (int i = 0; i < bankIndices.length; i++) {
           data[i] = stealData(dbus, bankIndices[i]);
           dataOffsets[i] = dOffsets[bankIndices[i]] +
               xOffset + yOffset*scanlineStride + bandOffsets[i];
        }
    } else {
        throw new RasterFormatException("ShortBandedRasters must have "+
            "BandedSampleModels");
    }
    verify();
}
项目:openjdk-jdk10    文件:ShortComponentRaster.java   
/**
 *  Constructs a ShortComponentRaster with the given SampleModel.
 *  The Raster's upper left corner is origin and it is the same
 *  size as the SampleModel.  A DataBuffer large enough to describe the
 *  Raster is automatically created.  SampleModel must be of type
 *  ComponentSampleModel or SinglePixelPackedSampleModel.
 *  @param sampleModel     The SampleModel that specifies the layout.
 *  @param origin          The Point that specified the origin.
 */
public ShortComponentRaster(SampleModel sampleModel, Point origin) {
    this(sampleModel,
         (DataBufferUShort) sampleModel.createDataBuffer(),
         new Rectangle(origin.x,
                       origin.y,
                       sampleModel.getWidth(),
                       sampleModel.getHeight()),
         origin,
         null);
}
项目:openjdk-jdk10    文件:ShortComponentRaster.java   
/**
 * Constructs a ShortComponentRaster with the given SampleModel
 * and DataBuffer.  The Raster's upper left corner is origin and
 * it is the same sizes the SampleModel.  The DataBuffer is not
 * initialized and must be a DataBufferUShort compatible with SampleModel.
 * SampleModel must be of type ComponentSampleModel or
 * SinglePixelPackedSampleModel.
 * @param sampleModel     The SampleModel that specifies the layout.
 * @param dataBuffer      The DataBufferUShort that contains the image data.
 * @param origin          The Point that specifies the origin.
 */
public ShortComponentRaster(SampleModel sampleModel,
                            DataBufferUShort dataBuffer,
                            Point origin)
{
    this(sampleModel,
         dataBuffer,
         new Rectangle(origin.x,
                       origin.y,
                       sampleModel.getWidth(),
                       sampleModel.getHeight()),
         origin,
         null);
}
项目:openjdk-jdk10    文件:ShortComponentRaster.java   
/**
 * Creates a Writable subRaster given a region of the Raster. The x and y
 * coordinates specify the horizontal and vertical offsets
 * from the upper-left corner of this Raster to the upper-left corner
 * of the subRaster.  A subset of the bands of the parent Raster may
 * be specified.  If this is null, then all the bands are present in the
 * subRaster. A translation to the subRaster may also be specified.
 * Note that the subRaster will reference the same
 * DataBuffers as the parent Raster, but using different offsets.
 * @param x               X offset.
 * @param y               Y offset.
 * @param width           Width (in pixels) of the subraster.
 * @param height          Height (in pixels) of the subraster.
 * @param x0              Translated X origin of the subraster.
 * @param y0              Translated Y origin of the subraster.
 * @param bandList        Array of band indices.
 * @exception RasterFormatException
 *            if the specified bounding box is outside of the parent Raster.
 */
public WritableRaster createWritableChild(int x, int y,
                                          int width, int height,
                                          int x0, int y0,
                                          int[] bandList) {
    if (x < this.minX) {
        throw new RasterFormatException("x lies outside the raster");
    }
    if (y < this.minY) {
        throw new RasterFormatException("y lies outside the raster");
    }
    if ((x+width < x) || (x+width > this.minX + this.width)) {
        throw new RasterFormatException("(x + width) is outside of Raster");
    }
    if ((y+height < y) || (y+height > this.minY + this.height)) {
        throw new RasterFormatException("(y + height) is outside of Raster");
    }

    SampleModel sm;

    if (bandList != null)
        sm = sampleModel.createSubsetSampleModel(bandList);
    else
        sm = sampleModel;

    int deltaX = x0 - x;
    int deltaY = y0 - y;

    return new ShortComponentRaster(sm,
                                   (DataBufferUShort) dataBuffer,
                                   new Rectangle(x0, y0, width, height),
                                   new Point(sampleModelTranslateX+deltaX,
                                             sampleModelTranslateY+deltaY),
                                   this);
}
项目:openjdk-jdk10    文件:ShortInterleavedRaster.java   
/**
 *  Constructs a ShortInterleavedRaster with the given SampleModel.
 *  The Raster's upper left corner is origin and it is the same
 *  size as the SampleModel.  A DataBuffer large enough to describe the
 *  Raster is automatically created.  SampleModel must be of type
 *  PixelInterleavedSampleModel or SinglePixelPackedSampleModel.
 *  @param sampleModel     The SampleModel that specifies the layout.
 *  @param origin          The Point that specified the origin.
 */
public ShortInterleavedRaster(SampleModel sampleModel, Point origin) {
    this(sampleModel,
         (DataBufferUShort) sampleModel.createDataBuffer(),
         new Rectangle(origin.x,
                       origin.y,
                       sampleModel.getWidth(),
                       sampleModel.getHeight()),
         origin,
         null);
}
项目:openjdk-jdk10    文件:ShortInterleavedRaster.java   
/**
 * Constructs a ShortInterleavedRaster with the given SampleModel
 * and DataBuffer.  The Raster's upper left corner is origin and
 * it is the same sizes the SampleModel.  The DataBuffer is not
 * initialized and must be a DataBufferUShort compatible with SampleModel.
 * SampleModel must be of type PixelInterleavedSampleModel or
 * SinglePixelPackedSampleModel.
 * @param sampleModel     The SampleModel that specifies the layout.
 * @param dataBuffer      The DataBufferUShort that contains the image data.
 * @param origin          The Point that specifies the origin.
 */
public ShortInterleavedRaster(SampleModel sampleModel,
                              DataBufferUShort dataBuffer,
                              Point origin)
{
    this(sampleModel,
         dataBuffer,
         new Rectangle(origin.x,
                       origin.y,
                       sampleModel.getWidth(),
                       sampleModel.getHeight()),
         origin,
         null);
}
项目:openjdk-jdk10    文件:ShortInterleavedRaster.java   
/**
 * Creates a Writable subRaster given a region of the Raster. The x and y
 * coordinates specify the horizontal and vertical offsets
 * from the upper-left corner of this Raster to the upper-left corner
 * of the subRaster.  A subset of the bands of the parent Raster may
 * be specified.  If this is null, then all the bands are present in the
 * subRaster. A translation to the subRaster may also be specified.
 * Note that the subRaster will reference the same
 * DataBuffers as the parent Raster, but using different offsets.
 * @param x               X offset.
 * @param y               Y offset.
 * @param width           Width (in pixels) of the subraster.
 * @param height          Height (in pixels) of the subraster.
 * @param x0              Translated X origin of the subraster.
 * @param y0              Translated Y origin of the subraster.
 * @param bandList        Array of band indices.
 * @exception RasterFormatException
 *            if the specified bounding box is outside of the parent Raster.
 */
public WritableRaster createWritableChild(int x, int y,
                                          int width, int height,
                                          int x0, int y0,
                                          int[] bandList) {
    if (x < this.minX) {
        throw new RasterFormatException("x lies outside the raster");
    }
    if (y < this.minY) {
        throw new RasterFormatException("y lies outside the raster");
    }
    if ((x+width < x) || (x+width > this.minX + this.width)) {
        throw new RasterFormatException("(x + width) is outside of Raster");
    }
    if ((y+height < y) || (y+height > this.minY + this.height)) {
        throw new RasterFormatException("(y + height) is outside of Raster");
    }

    SampleModel sm;

    if (bandList != null)
        sm = sampleModel.createSubsetSampleModel(bandList);
    else
        sm = sampleModel;

    int deltaX = x0 - x;
    int deltaY = y0 - y;

    return new ShortInterleavedRaster(sm,
                                   (DataBufferUShort) dataBuffer,
                                   new Rectangle(x0, y0, width, height),
                                   new Point(sampleModelTranslateX+deltaX,
                                             sampleModelTranslateY+deltaY),
                                   this);
}
项目:openjdk-jdk10    文件:ShortBandedRaster.java   
/**
 * Constructs a ShortBandedRaster with the given SampleModel.
 * The Raster's upper left corner is origin and it is the same
 * size as the SampleModel.  A DataBuffer large enough to describe the
 * Raster is automatically created.  SampleModel must be of type
 * BandedSampleModel.
 * @param sampleModel     The SampleModel that specifies the layout.
 * @param origin          The Point that specified the origin.
 */
public ShortBandedRaster(SampleModel sampleModel, Point origin) {
    this(sampleModel,
         (DataBufferUShort) sampleModel.createDataBuffer(),
         new Rectangle(origin.x,
                       origin.y,
                       sampleModel.getWidth(),
                       sampleModel.getHeight()),
         origin,
         null);
}
项目:openjdk-jdk10    文件:ShortBandedRaster.java   
/**
 * Constructs a ShortBandedRaster with the given SampleModel
 * and DataBuffer.  The Raster's upper left corner is origin and
 * it is the same size as the SampleModel.  The DataBuffer is not
 * initialized and must be a DataBufferUShort compatible with SampleModel.
 * SampleModel must be of type BandedSampleModel.
 * @param sampleModel     The SampleModel that specifies the layout.
 * @param dataBuffer      The DataBufferUShort that contains the image data.
 * @param origin          The Point that specifies the origin.
 */
public ShortBandedRaster(SampleModel sampleModel,
                         DataBufferUShort dataBuffer,
                         Point origin)
{
    this(sampleModel, dataBuffer,
         new Rectangle(origin.x, origin.y,
                       sampleModel.getWidth(),
                       sampleModel.getHeight()),
         origin, null);
}
项目:openjdk-jdk10    文件:ShortBandedRaster.java   
/**
 * Constructs a ShortBandedRaster with the given SampleModel,
 * DataBuffer, and parent.  DataBuffer must be a DataBufferUShort and
 * SampleModel must be of type BandedSampleModel.
 * When translated into the base Raster's
 * coordinate system, aRegion must be contained by the base Raster.
 * Origin is the coordinate in the new Raster's coordinate system of
 * the origin of the base Raster.  (The base Raster is the Raster's
 * ancestor which has no parent.)
 *
 * Note that this constructor should generally be called by other
 * constructors or create methods, it should not be used directly.
 * @param sampleModel     The SampleModel that specifies the layout.
 * @param dataBuffer      The DataBufferUShort that contains the image data.
 * @param aRegion         The Rectangle that specifies the image area.
 * @param origin          The Point that specifies the origin.
 * @param parent          The parent (if any) of this raster.
 */
public ShortBandedRaster(SampleModel sampleModel,
                         DataBufferUShort dataBuffer,
                         Rectangle aRegion,
                         Point origin,
                         ShortBandedRaster parent)
{
    super(sampleModel, dataBuffer, aRegion, origin, parent);
    this.maxX = minX + width;
    this.maxY = minY + height;

    if (sampleModel instanceof BandedSampleModel) {
        BandedSampleModel bsm = (BandedSampleModel)sampleModel;
        this.scanlineStride = bsm.getScanlineStride();
        int bankIndices[] = bsm.getBankIndices();
        int bandOffsets[] = bsm.getBandOffsets();
        int dOffsets[] = dataBuffer.getOffsets();
        dataOffsets = new int[bankIndices.length];
        data = new short[bankIndices.length][];
        int xOffset = aRegion.x - origin.x;
        int yOffset = aRegion.y - origin.y;
        for (int i = 0; i < bankIndices.length; i++) {
           data[i] = stealData(dataBuffer, bankIndices[i]);
           dataOffsets[i] = dOffsets[bankIndices[i]] +
               xOffset + yOffset*scanlineStride + bandOffsets[i];
        }
    } else {
        throw new RasterFormatException("ShortBandedRasters must have "+
            "BandedSampleModels");
    }
    verify();
}
项目:openjdk-jdk10    文件:ShortBandedRaster.java   
/**
 * Creates a Writable subRaster given a region of the Raster.  The x and y
 * coordinates specify the horizontal and vertical offsets
 * from the upper-left corner of this Raster to the upper-left corner
 * of the subRaster.  A subset of the bands of the parent Raster may
 * be specified.  If this is null, then all the bands are present in the
 * subRaster. A translation to the subRaster may also be specified.
 * Note that the subRaster will reference the same
 * DataBuffers as the parent Raster, but using different offsets.
 * @param x               X offset.
 * @param y               Y offset.
 * @param width           Width (in pixels) of the subraster.
 * @param height          Height (in pixels) of the subraster.
 * @param x0              Translated X origin of the subraster.
 * @param y0              Translated Y origin of the subraster.
 * @param bandList        Array of band indices.
 * @exception RasterFormatException
 *            if the specified bounding box is outside of the parent Raster.
 */
public WritableRaster createWritableChild(int x, int y,
                                          int width, int height,
                                          int x0, int y0,
                                          int bandList[]) {

    if (x < this.minX) {
        throw new RasterFormatException("x lies outside raster");
    }
    if (y < this.minY) {
        throw new RasterFormatException("y lies outside raster");
    }
    if ((x+width < x) || (x+width > this.minX + this.width)) {
        throw new RasterFormatException("(x + width) is outside of Raster");
    }
    if ((y+height < y) || (y+height > this.minY + this.height)) {
        throw new RasterFormatException("(y + height) is outside of Raster");
    }

    SampleModel sm;

    if (bandList != null)
        sm = sampleModel.createSubsetSampleModel(bandList);
    else
        sm = sampleModel;

    int deltaX = x0 - x;
    int deltaY = y0 - y;

    return new ShortBandedRaster(sm,
                                 (DataBufferUShort) dataBuffer,
                                 new Rectangle(x0, y0, width, height),
                                 new Point(sampleModelTranslateX+deltaX,
                                           sampleModelTranslateY+deltaY),
                                 this);

}
项目:openjdk-jdk10    文件:TestChildRasterOp.java   
private static void testShortRaster() {
    WritableRaster srcRaster, dstRaster;

    short[] pixels =
        { 11, 12, 13, 14,
          21, 22, 23, 24,
          31, 32, 33, 34,
          41, 42, 43, 44 };

    DataBuffer db = new DataBufferUShort(pixels, pixels.length);
    srcRaster =
        Raster.createInterleavedRaster(db, 4, 4, 4, 1, offsets, null);
    srcRaster = srcRaster.createWritableChild(1, 1, 3, 3, 0, 0, null);
    dstRaster = rop.filter(srcRaster, null);
}
项目:openjdk9    文件:ShortComponentRaster.java   
/**
 *  Constructs a ShortComponentRaster with the given SampleModel.
 *  The Raster's upper left corner is origin and it is the same
 *  size as the SampleModel.  A DataBuffer large enough to describe the
 *  Raster is automatically created.  SampleModel must be of type
 *  ComponentSampleModel or SinglePixelPackedSampleModel.
 *  @param sampleModel     The SampleModel that specifies the layout.
 *  @param origin          The Point that specified the origin.
 */
public ShortComponentRaster(SampleModel sampleModel, Point origin) {
    this(sampleModel,
         (DataBufferUShort) sampleModel.createDataBuffer(),
         new Rectangle(origin.x,
                       origin.y,
                       sampleModel.getWidth(),
                       sampleModel.getHeight()),
         origin,
         null);
}