java.awt.image.DataBufferByte#getOffset()源码实例Demo

下面列出了java.awt.image.DataBufferByte#getOffset() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: dragonwell8_jdk   文件: BytePackedRaster.java
/**
 * Constructs a BytePackedRaster with the given SampleModel,
 * DataBuffer, and parent.  DataBuffer must be a DataBufferByte and
 * SampleModel must be of type MultiPixelPackedSampleModel.
 * 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 DataBufferShort 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.
 *
 * @exception RasterFormatException if the parameters do not conform
 * to requirements of this Raster type.
 */
public BytePackedRaster(SampleModel sampleModel,
                        DataBuffer dataBuffer,
                        Rectangle aRegion,
                        Point origin,
                        BytePackedRaster parent){
    super(sampleModel,dataBuffer,aRegion,origin, parent);
    this.maxX = minX + width;
    this.maxY = minY + height;

    if (!(dataBuffer instanceof DataBufferByte)) {
       throw new RasterFormatException("BytePackedRasters must have" +
            "byte DataBuffers");
    }
    DataBufferByte dbb = (DataBufferByte)dataBuffer;
    this.data = stealData(dbb, 0);
    if (dbb.getNumBanks() != 1) {
        throw new
            RasterFormatException("DataBuffer for BytePackedRasters"+
                                  " must only have 1 bank.");
    }
    int dbOffset = dbb.getOffset();

    if (sampleModel instanceof MultiPixelPackedSampleModel) {
        MultiPixelPackedSampleModel mppsm =
            (MultiPixelPackedSampleModel)sampleModel;
        this.type = IntegerComponentRaster.TYPE_BYTE_BINARY_SAMPLES;
        pixelBitStride = mppsm.getPixelBitStride();
        if (pixelBitStride != 1 &&
            pixelBitStride != 2 &&
            pixelBitStride != 4) {
            throw new RasterFormatException
              ("BytePackedRasters must have a bit depth of 1, 2, or 4");
        }
        scanlineStride = mppsm.getScanlineStride();
        dataBitOffset = mppsm.getDataBitOffset() + dbOffset*8;
        int xOffset = aRegion.x - origin.x;
        int yOffset = aRegion.y - origin.y;
        dataBitOffset += xOffset*pixelBitStride + yOffset*scanlineStride*8;
        bitMask = (1 << pixelBitStride) -1;
        shiftOffset = 8 - pixelBitStride;
    } else {
        throw new RasterFormatException("BytePackedRasters must have"+
            "MultiPixelPackedSampleModel");
    }
    verify(false);
}
 
源代码2 项目: dragonwell8_jdk   文件: ByteInterleavedRaster.java
/**
 * Constructs a ByteInterleavedRaster with the given SampleModel,
 * DataBuffer, and parent.  DataBuffer must be a DataBufferByte and
 * SampleModel must be of type SinglePixelPackedSampleModel
 * or InterleavedSampleModel.
 * 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 DataBufferShort 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 ByteInterleavedRaster(SampleModel sampleModel,
                              DataBuffer dataBuffer,
                              Rectangle aRegion,
                              Point origin,
                              ByteInterleavedRaster parent) {
    super(sampleModel, dataBuffer, aRegion, origin, parent);
    this.maxX = minX + width;
    this.maxY = minY + height;

    if (!(dataBuffer instanceof DataBufferByte)) {
        throw new RasterFormatException("ByteInterleavedRasters must have " +
                                        "byte DataBuffers");
    }

    DataBufferByte dbb = (DataBufferByte)dataBuffer;
    this.data = stealData(dbb, 0);

    int xOffset = aRegion.x - origin.x;
    int yOffset = aRegion.y - origin.y;
    if (sampleModel instanceof PixelInterleavedSampleModel ||
        (sampleModel instanceof ComponentSampleModel &&
         isInterleaved((ComponentSampleModel)sampleModel))) {
        ComponentSampleModel csm = (ComponentSampleModel)sampleModel;
        this.scanlineStride = csm.getScanlineStride();
        this.pixelStride = csm.getPixelStride();
        this.dataOffsets = csm.getBandOffsets();
        for (int i = 0; i < getNumDataElements(); i++) {
            dataOffsets[i] += xOffset*pixelStride+yOffset*scanlineStride;
        }
    } else if (sampleModel instanceof SinglePixelPackedSampleModel) {
        SinglePixelPackedSampleModel sppsm =
                (SinglePixelPackedSampleModel)sampleModel;
        this.packed = true;
        this.bitMasks = sppsm.getBitMasks();
        this.bitOffsets = sppsm.getBitOffsets();
        this.scanlineStride = sppsm.getScanlineStride();
        this.pixelStride = 1;
        this.dataOffsets = new int[1];
        this.dataOffsets[0] = dbb.getOffset();
        dataOffsets[0] += xOffset*pixelStride+yOffset*scanlineStride;
    } else {
        throw new RasterFormatException("ByteInterleavedRasters must " +
          "have PixelInterleavedSampleModel, SinglePixelPackedSampleModel"+
          " or interleaved ComponentSampleModel.  Sample model is " +
          sampleModel);
    }
    this.bandOffset = this.dataOffsets[0];

    this.dbOffsetPacked = dataBuffer.getOffset() -
        sampleModelTranslateY*scanlineStride -
        sampleModelTranslateX*pixelStride;
    this.dbOffset = dbOffsetPacked -
        (xOffset*pixelStride+yOffset*scanlineStride);

    // Set inOrder to true if the data elements are in order and
    // have no gaps between them
    this.inOrder = false;
    if (numDataElements == pixelStride) {
        inOrder = true;
        for (int i = 1; i < numDataElements; i++) {
            if (dataOffsets[i] - dataOffsets[0] != i) {
                inOrder = false;
                break;
            }
        }
    }

    verify();
}
 
源代码3 项目: TencentKona-8   文件: BytePackedRaster.java
/**
 * Constructs a BytePackedRaster with the given SampleModel,
 * DataBuffer, and parent.  DataBuffer must be a DataBufferByte and
 * SampleModel must be of type MultiPixelPackedSampleModel.
 * 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 DataBufferShort 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.
 *
 * @exception RasterFormatException if the parameters do not conform
 * to requirements of this Raster type.
 */
public BytePackedRaster(SampleModel sampleModel,
                        DataBuffer dataBuffer,
                        Rectangle aRegion,
                        Point origin,
                        BytePackedRaster parent){
    super(sampleModel,dataBuffer,aRegion,origin, parent);
    this.maxX = minX + width;
    this.maxY = minY + height;

    if (!(dataBuffer instanceof DataBufferByte)) {
       throw new RasterFormatException("BytePackedRasters must have" +
            "byte DataBuffers");
    }
    DataBufferByte dbb = (DataBufferByte)dataBuffer;
    this.data = stealData(dbb, 0);
    if (dbb.getNumBanks() != 1) {
        throw new
            RasterFormatException("DataBuffer for BytePackedRasters"+
                                  " must only have 1 bank.");
    }
    int dbOffset = dbb.getOffset();

    if (sampleModel instanceof MultiPixelPackedSampleModel) {
        MultiPixelPackedSampleModel mppsm =
            (MultiPixelPackedSampleModel)sampleModel;
        this.type = IntegerComponentRaster.TYPE_BYTE_BINARY_SAMPLES;
        pixelBitStride = mppsm.getPixelBitStride();
        if (pixelBitStride != 1 &&
            pixelBitStride != 2 &&
            pixelBitStride != 4) {
            throw new RasterFormatException
              ("BytePackedRasters must have a bit depth of 1, 2, or 4");
        }
        scanlineStride = mppsm.getScanlineStride();
        dataBitOffset = mppsm.getDataBitOffset() + dbOffset*8;
        int xOffset = aRegion.x - origin.x;
        int yOffset = aRegion.y - origin.y;
        dataBitOffset += xOffset*pixelBitStride + yOffset*scanlineStride*8;
        bitMask = (1 << pixelBitStride) -1;
        shiftOffset = 8 - pixelBitStride;
    } else {
        throw new RasterFormatException("BytePackedRasters must have"+
            "MultiPixelPackedSampleModel");
    }
    verify(false);
}
 
源代码4 项目: jdk8u-dev-jdk   文件: BytePackedRaster.java
/**
 * Constructs a BytePackedRaster with the given SampleModel,
 * DataBuffer, and parent.  DataBuffer must be a DataBufferByte and
 * SampleModel must be of type MultiPixelPackedSampleModel.
 * 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 DataBufferShort 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.
 *
 * @exception RasterFormatException if the parameters do not conform
 * to requirements of this Raster type.
 */
public BytePackedRaster(SampleModel sampleModel,
                        DataBuffer dataBuffer,
                        Rectangle aRegion,
                        Point origin,
                        BytePackedRaster parent){
    super(sampleModel,dataBuffer,aRegion,origin, parent);
    this.maxX = minX + width;
    this.maxY = minY + height;

    if (!(dataBuffer instanceof DataBufferByte)) {
       throw new RasterFormatException("BytePackedRasters must have" +
            "byte DataBuffers");
    }
    DataBufferByte dbb = (DataBufferByte)dataBuffer;
    this.data = stealData(dbb, 0);
    if (dbb.getNumBanks() != 1) {
        throw new
            RasterFormatException("DataBuffer for BytePackedRasters"+
                                  " must only have 1 bank.");
    }
    int dbOffset = dbb.getOffset();

    if (sampleModel instanceof MultiPixelPackedSampleModel) {
        MultiPixelPackedSampleModel mppsm =
            (MultiPixelPackedSampleModel)sampleModel;
        this.type = IntegerComponentRaster.TYPE_BYTE_BINARY_SAMPLES;
        pixelBitStride = mppsm.getPixelBitStride();
        if (pixelBitStride != 1 &&
            pixelBitStride != 2 &&
            pixelBitStride != 4) {
            throw new RasterFormatException
              ("BytePackedRasters must have a bit depth of 1, 2, or 4");
        }
        scanlineStride = mppsm.getScanlineStride();
        dataBitOffset = mppsm.getDataBitOffset() + dbOffset*8;
        int xOffset = aRegion.x - origin.x;
        int yOffset = aRegion.y - origin.y;
        dataBitOffset += xOffset*pixelBitStride + yOffset*scanlineStride*8;
        bitMask = (1 << pixelBitStride) -1;
        shiftOffset = 8 - pixelBitStride;
    } else {
        throw new RasterFormatException("BytePackedRasters must have"+
            "MultiPixelPackedSampleModel");
    }
    verify(false);
}
 
源代码5 项目: jdk8u60   文件: BytePackedRaster.java
/**
 * Constructs a BytePackedRaster with the given SampleModel,
 * DataBuffer, and parent.  DataBuffer must be a DataBufferByte and
 * SampleModel must be of type MultiPixelPackedSampleModel.
 * 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 DataBufferShort 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.
 *
 * @exception RasterFormatException if the parameters do not conform
 * to requirements of this Raster type.
 */
public BytePackedRaster(SampleModel sampleModel,
                        DataBuffer dataBuffer,
                        Rectangle aRegion,
                        Point origin,
                        BytePackedRaster parent){
    super(sampleModel,dataBuffer,aRegion,origin, parent);
    this.maxX = minX + width;
    this.maxY = minY + height;

    if (!(dataBuffer instanceof DataBufferByte)) {
       throw new RasterFormatException("BytePackedRasters must have" +
            "byte DataBuffers");
    }
    DataBufferByte dbb = (DataBufferByte)dataBuffer;
    this.data = stealData(dbb, 0);
    if (dbb.getNumBanks() != 1) {
        throw new
            RasterFormatException("DataBuffer for BytePackedRasters"+
                                  " must only have 1 bank.");
    }
    int dbOffset = dbb.getOffset();

    if (sampleModel instanceof MultiPixelPackedSampleModel) {
        MultiPixelPackedSampleModel mppsm =
            (MultiPixelPackedSampleModel)sampleModel;
        this.type = IntegerComponentRaster.TYPE_BYTE_BINARY_SAMPLES;
        pixelBitStride = mppsm.getPixelBitStride();
        if (pixelBitStride != 1 &&
            pixelBitStride != 2 &&
            pixelBitStride != 4) {
            throw new RasterFormatException
              ("BytePackedRasters must have a bit depth of 1, 2, or 4");
        }
        scanlineStride = mppsm.getScanlineStride();
        dataBitOffset = mppsm.getDataBitOffset() + dbOffset*8;
        int xOffset = aRegion.x - origin.x;
        int yOffset = aRegion.y - origin.y;
        dataBitOffset += xOffset*pixelBitStride + yOffset*scanlineStride*8;
        bitMask = (1 << pixelBitStride) -1;
        shiftOffset = 8 - pixelBitStride;
    } else {
        throw new RasterFormatException("BytePackedRasters must have"+
            "MultiPixelPackedSampleModel");
    }
    verify(false);
}
 
源代码6 项目: jdk8u60   文件: ByteInterleavedRaster.java
/**
 * Constructs a ByteInterleavedRaster with the given SampleModel,
 * DataBuffer, and parent.  DataBuffer must be a DataBufferByte and
 * SampleModel must be of type SinglePixelPackedSampleModel
 * or InterleavedSampleModel.
 * 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 DataBufferShort 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 ByteInterleavedRaster(SampleModel sampleModel,
                              DataBuffer dataBuffer,
                              Rectangle aRegion,
                              Point origin,
                              ByteInterleavedRaster parent) {
    super(sampleModel, dataBuffer, aRegion, origin, parent);
    this.maxX = minX + width;
    this.maxY = minY + height;

    if (!(dataBuffer instanceof DataBufferByte)) {
        throw new RasterFormatException("ByteInterleavedRasters must have " +
                                        "byte DataBuffers");
    }

    DataBufferByte dbb = (DataBufferByte)dataBuffer;
    this.data = stealData(dbb, 0);

    int xOffset = aRegion.x - origin.x;
    int yOffset = aRegion.y - origin.y;
    if (sampleModel instanceof PixelInterleavedSampleModel ||
        (sampleModel instanceof ComponentSampleModel &&
         isInterleaved((ComponentSampleModel)sampleModel))) {
        ComponentSampleModel csm = (ComponentSampleModel)sampleModel;
        this.scanlineStride = csm.getScanlineStride();
        this.pixelStride = csm.getPixelStride();
        this.dataOffsets = csm.getBandOffsets();
        for (int i = 0; i < getNumDataElements(); i++) {
            dataOffsets[i] += xOffset*pixelStride+yOffset*scanlineStride;
        }
    } else if (sampleModel instanceof SinglePixelPackedSampleModel) {
        SinglePixelPackedSampleModel sppsm =
                (SinglePixelPackedSampleModel)sampleModel;
        this.packed = true;
        this.bitMasks = sppsm.getBitMasks();
        this.bitOffsets = sppsm.getBitOffsets();
        this.scanlineStride = sppsm.getScanlineStride();
        this.pixelStride = 1;
        this.dataOffsets = new int[1];
        this.dataOffsets[0] = dbb.getOffset();
        dataOffsets[0] += xOffset*pixelStride+yOffset*scanlineStride;
    } else {
        throw new RasterFormatException("ByteInterleavedRasters must " +
          "have PixelInterleavedSampleModel, SinglePixelPackedSampleModel"+
          " or interleaved ComponentSampleModel.  Sample model is " +
          sampleModel);
    }
    this.bandOffset = this.dataOffsets[0];

    this.dbOffsetPacked = dataBuffer.getOffset() -
        sampleModelTranslateY*scanlineStride -
        sampleModelTranslateX*pixelStride;
    this.dbOffset = dbOffsetPacked -
        (xOffset*pixelStride+yOffset*scanlineStride);

    // Set inOrder to true if the data elements are in order and
    // have no gaps between them
    this.inOrder = false;
    if (numDataElements == pixelStride) {
        inOrder = true;
        for (int i = 1; i < numDataElements; i++) {
            if (dataOffsets[i] - dataOffsets[0] != i) {
                inOrder = false;
                break;
            }
        }
    }

    verify();
}
 
源代码7 项目: openjdk-8   文件: BytePackedRaster.java
/**
 * Constructs a BytePackedRaster with the given SampleModel,
 * DataBuffer, and parent.  DataBuffer must be a DataBufferByte and
 * SampleModel must be of type MultiPixelPackedSampleModel.
 * 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 DataBufferShort 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.
 *
 * @exception RasterFormatException if the parameters do not conform
 * to requirements of this Raster type.
 */
public BytePackedRaster(SampleModel sampleModel,
                        DataBuffer dataBuffer,
                        Rectangle aRegion,
                        Point origin,
                        BytePackedRaster parent){
    super(sampleModel,dataBuffer,aRegion,origin, parent);
    this.maxX = minX + width;
    this.maxY = minY + height;

    if (!(dataBuffer instanceof DataBufferByte)) {
       throw new RasterFormatException("BytePackedRasters must have" +
            "byte DataBuffers");
    }
    DataBufferByte dbb = (DataBufferByte)dataBuffer;
    this.data = stealData(dbb, 0);
    if (dbb.getNumBanks() != 1) {
        throw new
            RasterFormatException("DataBuffer for BytePackedRasters"+
                                  " must only have 1 bank.");
    }
    int dbOffset = dbb.getOffset();

    if (sampleModel instanceof MultiPixelPackedSampleModel) {
        MultiPixelPackedSampleModel mppsm =
            (MultiPixelPackedSampleModel)sampleModel;
        this.type = IntegerComponentRaster.TYPE_BYTE_BINARY_SAMPLES;
        pixelBitStride = mppsm.getPixelBitStride();
        if (pixelBitStride != 1 &&
            pixelBitStride != 2 &&
            pixelBitStride != 4) {
            throw new RasterFormatException
              ("BytePackedRasters must have a bit depth of 1, 2, or 4");
        }
        scanlineStride = mppsm.getScanlineStride();
        dataBitOffset = mppsm.getDataBitOffset() + dbOffset*8;
        int xOffset = aRegion.x - origin.x;
        int yOffset = aRegion.y - origin.y;
        dataBitOffset += xOffset*pixelBitStride + yOffset*scanlineStride*8;
        bitMask = (1 << pixelBitStride) -1;
        shiftOffset = 8 - pixelBitStride;
    } else {
        throw new RasterFormatException("BytePackedRasters must have"+
            "MultiPixelPackedSampleModel");
    }
    verify(false);
}
 
源代码8 项目: openjdk-jdk8u   文件: ByteInterleavedRaster.java
/**
 * Constructs a ByteInterleavedRaster with the given SampleModel,
 * DataBuffer, and parent.  DataBuffer must be a DataBufferByte and
 * SampleModel must be of type SinglePixelPackedSampleModel
 * or InterleavedSampleModel.
 * 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 DataBufferShort 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 ByteInterleavedRaster(SampleModel sampleModel,
                              DataBuffer dataBuffer,
                              Rectangle aRegion,
                              Point origin,
                              ByteInterleavedRaster parent) {
    super(sampleModel, dataBuffer, aRegion, origin, parent);
    this.maxX = minX + width;
    this.maxY = minY + height;

    if (!(dataBuffer instanceof DataBufferByte)) {
        throw new RasterFormatException("ByteInterleavedRasters must have " +
                                        "byte DataBuffers");
    }

    DataBufferByte dbb = (DataBufferByte)dataBuffer;
    this.data = stealData(dbb, 0);

    int xOffset = aRegion.x - origin.x;
    int yOffset = aRegion.y - origin.y;
    if (sampleModel instanceof PixelInterleavedSampleModel ||
        (sampleModel instanceof ComponentSampleModel &&
         isInterleaved((ComponentSampleModel)sampleModel))) {
        ComponentSampleModel csm = (ComponentSampleModel)sampleModel;
        this.scanlineStride = csm.getScanlineStride();
        this.pixelStride = csm.getPixelStride();
        this.dataOffsets = csm.getBandOffsets();
        for (int i = 0; i < getNumDataElements(); i++) {
            dataOffsets[i] += xOffset*pixelStride+yOffset*scanlineStride;
        }
    } else if (sampleModel instanceof SinglePixelPackedSampleModel) {
        SinglePixelPackedSampleModel sppsm =
                (SinglePixelPackedSampleModel)sampleModel;
        this.packed = true;
        this.bitMasks = sppsm.getBitMasks();
        this.bitOffsets = sppsm.getBitOffsets();
        this.scanlineStride = sppsm.getScanlineStride();
        this.pixelStride = 1;
        this.dataOffsets = new int[1];
        this.dataOffsets[0] = dbb.getOffset();
        dataOffsets[0] += xOffset*pixelStride+yOffset*scanlineStride;
    } else {
        throw new RasterFormatException("ByteInterleavedRasters must " +
          "have PixelInterleavedSampleModel, SinglePixelPackedSampleModel"+
          " or interleaved ComponentSampleModel.  Sample model is " +
          sampleModel);
    }
    this.bandOffset = this.dataOffsets[0];

    this.dbOffsetPacked = dataBuffer.getOffset() -
        sampleModelTranslateY*scanlineStride -
        sampleModelTranslateX*pixelStride;
    this.dbOffset = dbOffsetPacked -
        (xOffset*pixelStride+yOffset*scanlineStride);

    // Set inOrder to true if the data elements are in order and
    // have no gaps between them
    this.inOrder = false;
    if (numDataElements == pixelStride) {
        inOrder = true;
        for (int i = 1; i < numDataElements; i++) {
            if (dataOffsets[i] - dataOffsets[0] != i) {
                inOrder = false;
                break;
            }
        }
    }

    verify();
}
 
源代码9 项目: jdk8u-dev-jdk   文件: ByteInterleavedRaster.java
/**
 * Constructs a ByteInterleavedRaster with the given SampleModel,
 * DataBuffer, and parent.  DataBuffer must be a DataBufferByte and
 * SampleModel must be of type SinglePixelPackedSampleModel
 * or InterleavedSampleModel.
 * 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 DataBufferShort 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 ByteInterleavedRaster(SampleModel sampleModel,
                              DataBuffer dataBuffer,
                              Rectangle aRegion,
                              Point origin,
                              ByteInterleavedRaster parent) {
    super(sampleModel, dataBuffer, aRegion, origin, parent);
    this.maxX = minX + width;
    this.maxY = minY + height;

    if (!(dataBuffer instanceof DataBufferByte)) {
        throw new RasterFormatException("ByteInterleavedRasters must have " +
                                        "byte DataBuffers");
    }

    DataBufferByte dbb = (DataBufferByte)dataBuffer;
    this.data = stealData(dbb, 0);

    int xOffset = aRegion.x - origin.x;
    int yOffset = aRegion.y - origin.y;
    if (sampleModel instanceof PixelInterleavedSampleModel ||
        (sampleModel instanceof ComponentSampleModel &&
         isInterleaved((ComponentSampleModel)sampleModel))) {
        ComponentSampleModel csm = (ComponentSampleModel)sampleModel;
        this.scanlineStride = csm.getScanlineStride();
        this.pixelStride = csm.getPixelStride();
        this.dataOffsets = csm.getBandOffsets();
        for (int i = 0; i < getNumDataElements(); i++) {
            dataOffsets[i] += xOffset*pixelStride+yOffset*scanlineStride;
        }
    } else if (sampleModel instanceof SinglePixelPackedSampleModel) {
        SinglePixelPackedSampleModel sppsm =
                (SinglePixelPackedSampleModel)sampleModel;
        this.packed = true;
        this.bitMasks = sppsm.getBitMasks();
        this.bitOffsets = sppsm.getBitOffsets();
        this.scanlineStride = sppsm.getScanlineStride();
        this.pixelStride = 1;
        this.dataOffsets = new int[1];
        this.dataOffsets[0] = dbb.getOffset();
        dataOffsets[0] += xOffset*pixelStride+yOffset*scanlineStride;
    } else {
        throw new RasterFormatException("ByteInterleavedRasters must " +
          "have PixelInterleavedSampleModel, SinglePixelPackedSampleModel"+
          " or interleaved ComponentSampleModel.  Sample model is " +
          sampleModel);
    }
    this.bandOffset = this.dataOffsets[0];

    this.dbOffsetPacked = dataBuffer.getOffset() -
        sampleModelTranslateY*scanlineStride -
        sampleModelTranslateX*pixelStride;
    this.dbOffset = dbOffsetPacked -
        (xOffset*pixelStride+yOffset*scanlineStride);

    // Set inOrder to true if the data elements are in order and
    // have no gaps between them
    this.inOrder = false;
    if (numDataElements == pixelStride) {
        inOrder = true;
        for (int i = 1; i < numDataElements; i++) {
            if (dataOffsets[i] - dataOffsets[0] != i) {
                inOrder = false;
                break;
            }
        }
    }

    verify();
}
 
/**
 * Constructs a ByteInterleavedRaster with the given SampleModel,
 * DataBuffer, and parent.  DataBuffer must be a DataBufferByte and
 * SampleModel must be of type SinglePixelPackedSampleModel
 * or InterleavedSampleModel.
 * 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 DataBufferShort 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 ByteInterleavedRaster(SampleModel sampleModel,
                              DataBuffer dataBuffer,
                              Rectangle aRegion,
                              Point origin,
                              ByteInterleavedRaster parent) {
    super(sampleModel, dataBuffer, aRegion, origin, parent);
    this.maxX = minX + width;
    this.maxY = minY + height;

    if (!(dataBuffer instanceof DataBufferByte)) {
        throw new RasterFormatException("ByteInterleavedRasters must have " +
                                        "byte DataBuffers");
    }

    DataBufferByte dbb = (DataBufferByte)dataBuffer;
    this.data = stealData(dbb, 0);

    int xOffset = aRegion.x - origin.x;
    int yOffset = aRegion.y - origin.y;
    if (sampleModel instanceof PixelInterleavedSampleModel ||
        (sampleModel instanceof ComponentSampleModel &&
         isInterleaved((ComponentSampleModel)sampleModel))) {
        ComponentSampleModel csm = (ComponentSampleModel)sampleModel;
        this.scanlineStride = csm.getScanlineStride();
        this.pixelStride = csm.getPixelStride();
        this.dataOffsets = csm.getBandOffsets();
        for (int i = 0; i < getNumDataElements(); i++) {
            dataOffsets[i] += xOffset*pixelStride+yOffset*scanlineStride;
        }
    } else if (sampleModel instanceof SinglePixelPackedSampleModel) {
        SinglePixelPackedSampleModel sppsm =
                (SinglePixelPackedSampleModel)sampleModel;
        this.packed = true;
        this.bitMasks = sppsm.getBitMasks();
        this.bitOffsets = sppsm.getBitOffsets();
        this.scanlineStride = sppsm.getScanlineStride();
        this.pixelStride = 1;
        this.dataOffsets = new int[1];
        this.dataOffsets[0] = dbb.getOffset();
        dataOffsets[0] += xOffset*pixelStride+yOffset*scanlineStride;
    } else {
        throw new RasterFormatException("ByteInterleavedRasters must " +
          "have PixelInterleavedSampleModel, SinglePixelPackedSampleModel"+
          " or interleaved ComponentSampleModel.  Sample model is " +
          sampleModel);
    }
    this.bandOffset = this.dataOffsets[0];

    this.dbOffsetPacked = dataBuffer.getOffset() -
        sampleModelTranslateY*scanlineStride -
        sampleModelTranslateX*pixelStride;
    this.dbOffset = dbOffsetPacked -
        (xOffset*pixelStride+yOffset*scanlineStride);

    // Set inOrder to true if the data elements are in order and
    // have no gaps between them
    this.inOrder = false;
    if (numDataElements == pixelStride) {
        inOrder = true;
        for (int i = 1; i < numDataElements; i++) {
            if (dataOffsets[i] - dataOffsets[0] != i) {
                inOrder = false;
                break;
            }
        }
    }

    verify();
}
 
源代码11 项目: Bytecoder   文件: BytePackedRaster.java
/**
 * Constructs a BytePackedRaster with the given SampleModel,
 * DataBuffer, and parent.  DataBuffer must be a DataBufferByte and
 * SampleModel must be of type MultiPixelPackedSampleModel.
 * 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 DataBufferByte 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.
 *
 * @exception RasterFormatException if the parameters do not conform
 * to requirements of this Raster type.
 */
public BytePackedRaster(SampleModel sampleModel,
                        DataBufferByte dataBuffer,
                        Rectangle aRegion,
                        Point origin,
                        BytePackedRaster parent)
{
    super(sampleModel,dataBuffer,aRegion,origin, parent);
    this.maxX = minX + width;
    this.maxY = minY + height;

    this.data = stealData(dataBuffer, 0);
    if (dataBuffer.getNumBanks() != 1) {
        throw new
            RasterFormatException("DataBuffer for BytePackedRasters"+
                                  " must only have 1 bank.");
    }
    int dbOffset = dataBuffer.getOffset();

    if (sampleModel instanceof MultiPixelPackedSampleModel) {
        MultiPixelPackedSampleModel mppsm =
            (MultiPixelPackedSampleModel)sampleModel;
        this.type = IntegerComponentRaster.TYPE_BYTE_BINARY_SAMPLES;
        pixelBitStride = mppsm.getPixelBitStride();
        if (pixelBitStride != 1 &&
            pixelBitStride != 2 &&
            pixelBitStride != 4) {
            throw new RasterFormatException
              ("BytePackedRasters must have a bit depth of 1, 2, or 4");
        }
        scanlineStride = mppsm.getScanlineStride();
        dataBitOffset = mppsm.getDataBitOffset() + dbOffset*8;
        int xOffset = aRegion.x - origin.x;
        int yOffset = aRegion.y - origin.y;
        dataBitOffset += xOffset*pixelBitStride + yOffset*scanlineStride*8;
        bitMask = (1 << pixelBitStride) -1;
        shiftOffset = 8 - pixelBitStride;
    } else {
        throw new RasterFormatException("BytePackedRasters must have"+
            "MultiPixelPackedSampleModel");
    }
    verify(false);
}
 
源代码12 项目: jdk8u-jdk   文件: ByteInterleavedRaster.java
/**
 * Constructs a ByteInterleavedRaster with the given SampleModel,
 * DataBuffer, and parent.  DataBuffer must be a DataBufferByte and
 * SampleModel must be of type SinglePixelPackedSampleModel
 * or InterleavedSampleModel.
 * 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 DataBufferShort 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 ByteInterleavedRaster(SampleModel sampleModel,
                              DataBuffer dataBuffer,
                              Rectangle aRegion,
                              Point origin,
                              ByteInterleavedRaster parent) {
    super(sampleModel, dataBuffer, aRegion, origin, parent);
    this.maxX = minX + width;
    this.maxY = minY + height;

    if (!(dataBuffer instanceof DataBufferByte)) {
        throw new RasterFormatException("ByteInterleavedRasters must have " +
                                        "byte DataBuffers");
    }

    DataBufferByte dbb = (DataBufferByte)dataBuffer;
    this.data = stealData(dbb, 0);

    int xOffset = aRegion.x - origin.x;
    int yOffset = aRegion.y - origin.y;
    if (sampleModel instanceof PixelInterleavedSampleModel ||
        (sampleModel instanceof ComponentSampleModel &&
         isInterleaved((ComponentSampleModel)sampleModel))) {
        ComponentSampleModel csm = (ComponentSampleModel)sampleModel;
        this.scanlineStride = csm.getScanlineStride();
        this.pixelStride = csm.getPixelStride();
        this.dataOffsets = csm.getBandOffsets();
        for (int i = 0; i < getNumDataElements(); i++) {
            dataOffsets[i] += xOffset*pixelStride+yOffset*scanlineStride;
        }
    } else if (sampleModel instanceof SinglePixelPackedSampleModel) {
        SinglePixelPackedSampleModel sppsm =
                (SinglePixelPackedSampleModel)sampleModel;
        this.packed = true;
        this.bitMasks = sppsm.getBitMasks();
        this.bitOffsets = sppsm.getBitOffsets();
        this.scanlineStride = sppsm.getScanlineStride();
        this.pixelStride = 1;
        this.dataOffsets = new int[1];
        this.dataOffsets[0] = dbb.getOffset();
        dataOffsets[0] += xOffset*pixelStride+yOffset*scanlineStride;
    } else {
        throw new RasterFormatException("ByteInterleavedRasters must " +
          "have PixelInterleavedSampleModel, SinglePixelPackedSampleModel"+
          " or interleaved ComponentSampleModel.  Sample model is " +
          sampleModel);
    }
    this.bandOffset = this.dataOffsets[0];

    this.dbOffsetPacked = dataBuffer.getOffset() -
        sampleModelTranslateY*scanlineStride -
        sampleModelTranslateX*pixelStride;
    this.dbOffset = dbOffsetPacked -
        (xOffset*pixelStride+yOffset*scanlineStride);

    // Set inOrder to true if the data elements are in order and
    // have no gaps between them
    this.inOrder = false;
    if (numDataElements == pixelStride) {
        inOrder = true;
        for (int i = 1; i < numDataElements; i++) {
            if (dataOffsets[i] - dataOffsets[0] != i) {
                inOrder = false;
                break;
            }
        }
    }

    verify();
}
 
源代码13 项目: openjdk-jdk9   文件: BytePackedRaster.java
/**
 * Constructs a BytePackedRaster with the given SampleModel,
 * DataBuffer, and parent.  DataBuffer must be a DataBufferByte and
 * SampleModel must be of type MultiPixelPackedSampleModel.
 * 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 DataBufferByte 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.
 *
 * @exception RasterFormatException if the parameters do not conform
 * to requirements of this Raster type.
 */
public BytePackedRaster(SampleModel sampleModel,
                        DataBufferByte dataBuffer,
                        Rectangle aRegion,
                        Point origin,
                        BytePackedRaster parent)
{
    super(sampleModel,dataBuffer,aRegion,origin, parent);
    this.maxX = minX + width;
    this.maxY = minY + height;

    this.data = stealData(dataBuffer, 0);
    if (dataBuffer.getNumBanks() != 1) {
        throw new
            RasterFormatException("DataBuffer for BytePackedRasters"+
                                  " must only have 1 bank.");
    }
    int dbOffset = dataBuffer.getOffset();

    if (sampleModel instanceof MultiPixelPackedSampleModel) {
        MultiPixelPackedSampleModel mppsm =
            (MultiPixelPackedSampleModel)sampleModel;
        this.type = IntegerComponentRaster.TYPE_BYTE_BINARY_SAMPLES;
        pixelBitStride = mppsm.getPixelBitStride();
        if (pixelBitStride != 1 &&
            pixelBitStride != 2 &&
            pixelBitStride != 4) {
            throw new RasterFormatException
              ("BytePackedRasters must have a bit depth of 1, 2, or 4");
        }
        scanlineStride = mppsm.getScanlineStride();
        dataBitOffset = mppsm.getDataBitOffset() + dbOffset*8;
        int xOffset = aRegion.x - origin.x;
        int yOffset = aRegion.y - origin.y;
        dataBitOffset += xOffset*pixelBitStride + yOffset*scanlineStride*8;
        bitMask = (1 << pixelBitStride) -1;
        shiftOffset = 8 - pixelBitStride;
    } else {
        throw new RasterFormatException("BytePackedRasters must have"+
            "MultiPixelPackedSampleModel");
    }
    verify(false);
}
 
源代码14 项目: openjdk-jdk9   文件: ByteInterleavedRaster.java
/**
 * Constructs a ByteInterleavedRaster with the given SampleModel,
 * DataBuffer, and parent.  DataBuffer must be a DataBufferByte and
 * SampleModel must be of type SinglePixelPackedSampleModel
 * or InterleavedSampleModel.
 * 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 DataBufferByte 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 ByteInterleavedRaster(SampleModel sampleModel,
                             DataBufferByte dataBuffer,
                             Rectangle aRegion,
                             Point origin,
                             ByteInterleavedRaster parent)
{
    super(sampleModel, dataBuffer, aRegion, origin, parent);
    this.maxX = minX + width;
    this.maxY = minY + height;

    this.data = stealData(dataBuffer, 0);

    int xOffset = aRegion.x - origin.x;
    int yOffset = aRegion.y - origin.y;
    if (sampleModel instanceof PixelInterleavedSampleModel ||
        (sampleModel instanceof ComponentSampleModel &&
         isInterleaved((ComponentSampleModel)sampleModel))) {
        ComponentSampleModel csm = (ComponentSampleModel)sampleModel;
        this.scanlineStride = csm.getScanlineStride();
        this.pixelStride = csm.getPixelStride();
        this.dataOffsets = csm.getBandOffsets();
        for (int i = 0; i < getNumDataElements(); i++) {
            dataOffsets[i] += xOffset*pixelStride+yOffset*scanlineStride;
        }
    } else if (sampleModel instanceof SinglePixelPackedSampleModel) {
        SinglePixelPackedSampleModel sppsm =
                (SinglePixelPackedSampleModel)sampleModel;
        this.packed = true;
        this.bitMasks = sppsm.getBitMasks();
        this.bitOffsets = sppsm.getBitOffsets();
        this.scanlineStride = sppsm.getScanlineStride();
        this.pixelStride = 1;
        this.dataOffsets = new int[1];
        this.dataOffsets[0] = dataBuffer.getOffset();
        dataOffsets[0] += xOffset*pixelStride+yOffset*scanlineStride;
    } else {
        throw new RasterFormatException("ByteInterleavedRasters must " +
          "have PixelInterleavedSampleModel, SinglePixelPackedSampleModel"+
          " or interleaved ComponentSampleModel.  Sample model is " +
          sampleModel);
    }
    this.bandOffset = this.dataOffsets[0];

    this.dbOffsetPacked = dataBuffer.getOffset() -
        sampleModelTranslateY*scanlineStride -
        sampleModelTranslateX*pixelStride;
    this.dbOffset = dbOffsetPacked -
        (xOffset*pixelStride+yOffset*scanlineStride);

    // Set inOrder to true if the data elements are in order and
    // have no gaps between them
    this.inOrder = false;
    if (numDataElements == pixelStride) {
        inOrder = true;
        for (int i = 1; i < numDataElements; i++) {
            if (dataOffsets[i] - dataOffsets[0] != i) {
                inOrder = false;
                break;
            }
        }
    }

    verify();
}
 
源代码15 项目: jdk8u-jdk   文件: BytePackedRaster.java
/**
 * Constructs a BytePackedRaster with the given SampleModel,
 * DataBuffer, and parent.  DataBuffer must be a DataBufferByte and
 * SampleModel must be of type MultiPixelPackedSampleModel.
 * 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 DataBufferShort 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.
 *
 * @exception RasterFormatException if the parameters do not conform
 * to requirements of this Raster type.
 */
public BytePackedRaster(SampleModel sampleModel,
                        DataBuffer dataBuffer,
                        Rectangle aRegion,
                        Point origin,
                        BytePackedRaster parent){
    super(sampleModel,dataBuffer,aRegion,origin, parent);
    this.maxX = minX + width;
    this.maxY = minY + height;

    if (!(dataBuffer instanceof DataBufferByte)) {
       throw new RasterFormatException("BytePackedRasters must have" +
            "byte DataBuffers");
    }
    DataBufferByte dbb = (DataBufferByte)dataBuffer;
    this.data = stealData(dbb, 0);
    if (dbb.getNumBanks() != 1) {
        throw new
            RasterFormatException("DataBuffer for BytePackedRasters"+
                                  " must only have 1 bank.");
    }
    int dbOffset = dbb.getOffset();

    if (sampleModel instanceof MultiPixelPackedSampleModel) {
        MultiPixelPackedSampleModel mppsm =
            (MultiPixelPackedSampleModel)sampleModel;
        this.type = IntegerComponentRaster.TYPE_BYTE_BINARY_SAMPLES;
        pixelBitStride = mppsm.getPixelBitStride();
        if (pixelBitStride != 1 &&
            pixelBitStride != 2 &&
            pixelBitStride != 4) {
            throw new RasterFormatException
              ("BytePackedRasters must have a bit depth of 1, 2, or 4");
        }
        scanlineStride = mppsm.getScanlineStride();
        dataBitOffset = mppsm.getDataBitOffset() + dbOffset*8;
        int xOffset = aRegion.x - origin.x;
        int yOffset = aRegion.y - origin.y;
        dataBitOffset += xOffset*pixelBitStride + yOffset*scanlineStride*8;
        bitMask = (1 << pixelBitStride) -1;
        shiftOffset = 8 - pixelBitStride;
    } else {
        throw new RasterFormatException("BytePackedRasters must have"+
            "MultiPixelPackedSampleModel");
    }
    verify(false);
}
 
源代码16 项目: jdk8u-jdk   文件: ByteInterleavedRaster.java
/**
 * Constructs a ByteInterleavedRaster with the given SampleModel,
 * DataBuffer, and parent.  DataBuffer must be a DataBufferByte and
 * SampleModel must be of type SinglePixelPackedSampleModel
 * or InterleavedSampleModel.
 * 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 DataBufferShort 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 ByteInterleavedRaster(SampleModel sampleModel,
                              DataBuffer dataBuffer,
                              Rectangle aRegion,
                              Point origin,
                              ByteInterleavedRaster parent) {
    super(sampleModel, dataBuffer, aRegion, origin, parent);
    this.maxX = minX + width;
    this.maxY = minY + height;

    if (!(dataBuffer instanceof DataBufferByte)) {
        throw new RasterFormatException("ByteInterleavedRasters must have " +
                                        "byte DataBuffers");
    }

    DataBufferByte dbb = (DataBufferByte)dataBuffer;
    this.data = stealData(dbb, 0);

    int xOffset = aRegion.x - origin.x;
    int yOffset = aRegion.y - origin.y;
    if (sampleModel instanceof PixelInterleavedSampleModel ||
        (sampleModel instanceof ComponentSampleModel &&
         isInterleaved((ComponentSampleModel)sampleModel))) {
        ComponentSampleModel csm = (ComponentSampleModel)sampleModel;
        this.scanlineStride = csm.getScanlineStride();
        this.pixelStride = csm.getPixelStride();
        this.dataOffsets = csm.getBandOffsets();
        for (int i = 0; i < getNumDataElements(); i++) {
            dataOffsets[i] += xOffset*pixelStride+yOffset*scanlineStride;
        }
    } else if (sampleModel instanceof SinglePixelPackedSampleModel) {
        SinglePixelPackedSampleModel sppsm =
                (SinglePixelPackedSampleModel)sampleModel;
        this.packed = true;
        this.bitMasks = sppsm.getBitMasks();
        this.bitOffsets = sppsm.getBitOffsets();
        this.scanlineStride = sppsm.getScanlineStride();
        this.pixelStride = 1;
        this.dataOffsets = new int[1];
        this.dataOffsets[0] = dbb.getOffset();
        dataOffsets[0] += xOffset*pixelStride+yOffset*scanlineStride;
    } else {
        throw new RasterFormatException("ByteInterleavedRasters must " +
          "have PixelInterleavedSampleModel, SinglePixelPackedSampleModel"+
          " or interleaved ComponentSampleModel.  Sample model is " +
          sampleModel);
    }
    this.bandOffset = this.dataOffsets[0];

    this.dbOffsetPacked = dataBuffer.getOffset() -
        sampleModelTranslateY*scanlineStride -
        sampleModelTranslateX*pixelStride;
    this.dbOffset = dbOffsetPacked -
        (xOffset*pixelStride+yOffset*scanlineStride);

    // Set inOrder to true if the data elements are in order and
    // have no gaps between them
    this.inOrder = false;
    if (numDataElements == pixelStride) {
        inOrder = true;
        for (int i = 1; i < numDataElements; i++) {
            if (dataOffsets[i] - dataOffsets[0] != i) {
                inOrder = false;
                break;
            }
        }
    }

    verify();
}
 
源代码17 项目: openjdk-8   文件: ByteInterleavedRaster.java
/**
 * Constructs a ByteInterleavedRaster with the given SampleModel,
 * DataBuffer, and parent.  DataBuffer must be a DataBufferByte and
 * SampleModel must be of type SinglePixelPackedSampleModel
 * or InterleavedSampleModel.
 * 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 DataBufferShort 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 ByteInterleavedRaster(SampleModel sampleModel,
                              DataBuffer dataBuffer,
                              Rectangle aRegion,
                              Point origin,
                              ByteInterleavedRaster parent) {
    super(sampleModel, dataBuffer, aRegion, origin, parent);
    this.maxX = minX + width;
    this.maxY = minY + height;

    if (!(dataBuffer instanceof DataBufferByte)) {
        throw new RasterFormatException("ByteInterleavedRasters must have " +
                                        "byte DataBuffers");
    }

    DataBufferByte dbb = (DataBufferByte)dataBuffer;
    this.data = stealData(dbb, 0);

    int xOffset = aRegion.x - origin.x;
    int yOffset = aRegion.y - origin.y;
    if (sampleModel instanceof PixelInterleavedSampleModel ||
        (sampleModel instanceof ComponentSampleModel &&
         isInterleaved((ComponentSampleModel)sampleModel))) {
        ComponentSampleModel csm = (ComponentSampleModel)sampleModel;
        this.scanlineStride = csm.getScanlineStride();
        this.pixelStride = csm.getPixelStride();
        this.dataOffsets = csm.getBandOffsets();
        for (int i = 0; i < getNumDataElements(); i++) {
            dataOffsets[i] += xOffset*pixelStride+yOffset*scanlineStride;
        }
    } else if (sampleModel instanceof SinglePixelPackedSampleModel) {
        SinglePixelPackedSampleModel sppsm =
                (SinglePixelPackedSampleModel)sampleModel;
        this.packed = true;
        this.bitMasks = sppsm.getBitMasks();
        this.bitOffsets = sppsm.getBitOffsets();
        this.scanlineStride = sppsm.getScanlineStride();
        this.pixelStride = 1;
        this.dataOffsets = new int[1];
        this.dataOffsets[0] = dbb.getOffset();
        dataOffsets[0] += xOffset*pixelStride+yOffset*scanlineStride;
    } else {
        throw new RasterFormatException("ByteInterleavedRasters must " +
          "have PixelInterleavedSampleModel, SinglePixelPackedSampleModel"+
          " or interleaved ComponentSampleModel.  Sample model is " +
          sampleModel);
    }
    this.bandOffset = this.dataOffsets[0];

    this.dbOffsetPacked = dataBuffer.getOffset() -
        sampleModelTranslateY*scanlineStride -
        sampleModelTranslateX*pixelStride;
    this.dbOffset = dbOffsetPacked -
        (xOffset*pixelStride+yOffset*scanlineStride);

    // Set inOrder to true if the data elements are in order and
    // have no gaps between them
    this.inOrder = false;
    if (numDataElements == pixelStride) {
        inOrder = true;
        for (int i = 1; i < numDataElements; i++) {
            if (dataOffsets[i] - dataOffsets[0] != i) {
                inOrder = false;
                break;
            }
        }
    }

    verify();
}
 
源代码18 项目: jdk8u_jdk   文件: BytePackedRaster.java
/**
 * Constructs a BytePackedRaster with the given SampleModel,
 * DataBuffer, and parent.  DataBuffer must be a DataBufferByte and
 * SampleModel must be of type MultiPixelPackedSampleModel.
 * 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 DataBufferShort 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.
 *
 * @exception RasterFormatException if the parameters do not conform
 * to requirements of this Raster type.
 */
public BytePackedRaster(SampleModel sampleModel,
                        DataBuffer dataBuffer,
                        Rectangle aRegion,
                        Point origin,
                        BytePackedRaster parent){
    super(sampleModel,dataBuffer,aRegion,origin, parent);
    this.maxX = minX + width;
    this.maxY = minY + height;

    if (!(dataBuffer instanceof DataBufferByte)) {
       throw new RasterFormatException("BytePackedRasters must have" +
            "byte DataBuffers");
    }
    DataBufferByte dbb = (DataBufferByte)dataBuffer;
    this.data = stealData(dbb, 0);
    if (dbb.getNumBanks() != 1) {
        throw new
            RasterFormatException("DataBuffer for BytePackedRasters"+
                                  " must only have 1 bank.");
    }
    int dbOffset = dbb.getOffset();

    if (sampleModel instanceof MultiPixelPackedSampleModel) {
        MultiPixelPackedSampleModel mppsm =
            (MultiPixelPackedSampleModel)sampleModel;
        this.type = IntegerComponentRaster.TYPE_BYTE_BINARY_SAMPLES;
        pixelBitStride = mppsm.getPixelBitStride();
        if (pixelBitStride != 1 &&
            pixelBitStride != 2 &&
            pixelBitStride != 4) {
            throw new RasterFormatException
              ("BytePackedRasters must have a bit depth of 1, 2, or 4");
        }
        scanlineStride = mppsm.getScanlineStride();
        dataBitOffset = mppsm.getDataBitOffset() + dbOffset*8;
        int xOffset = aRegion.x - origin.x;
        int yOffset = aRegion.y - origin.y;
        dataBitOffset += xOffset*pixelBitStride + yOffset*scanlineStride*8;
        bitMask = (1 << pixelBitStride) -1;
        shiftOffset = 8 - pixelBitStride;
    } else {
        throw new RasterFormatException("BytePackedRasters must have"+
            "MultiPixelPackedSampleModel");
    }
    verify(false);
}
 
源代码19 项目: openjdk-8-source   文件: BytePackedRaster.java
/**
 * Constructs a BytePackedRaster with the given SampleModel,
 * DataBuffer, and parent.  DataBuffer must be a DataBufferByte and
 * SampleModel must be of type MultiPixelPackedSampleModel.
 * 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 DataBufferShort 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.
 *
 * @exception RasterFormatException if the parameters do not conform
 * to requirements of this Raster type.
 */
public BytePackedRaster(SampleModel sampleModel,
                        DataBuffer dataBuffer,
                        Rectangle aRegion,
                        Point origin,
                        BytePackedRaster parent){
    super(sampleModel,dataBuffer,aRegion,origin, parent);
    this.maxX = minX + width;
    this.maxY = minY + height;

    if (!(dataBuffer instanceof DataBufferByte)) {
       throw new RasterFormatException("BytePackedRasters must have" +
            "byte DataBuffers");
    }
    DataBufferByte dbb = (DataBufferByte)dataBuffer;
    this.data = stealData(dbb, 0);
    if (dbb.getNumBanks() != 1) {
        throw new
            RasterFormatException("DataBuffer for BytePackedRasters"+
                                  " must only have 1 bank.");
    }
    int dbOffset = dbb.getOffset();

    if (sampleModel instanceof MultiPixelPackedSampleModel) {
        MultiPixelPackedSampleModel mppsm =
            (MultiPixelPackedSampleModel)sampleModel;
        this.type = IntegerComponentRaster.TYPE_BYTE_BINARY_SAMPLES;
        pixelBitStride = mppsm.getPixelBitStride();
        if (pixelBitStride != 1 &&
            pixelBitStride != 2 &&
            pixelBitStride != 4) {
            throw new RasterFormatException
              ("BytePackedRasters must have a bit depth of 1, 2, or 4");
        }
        scanlineStride = mppsm.getScanlineStride();
        dataBitOffset = mppsm.getDataBitOffset() + dbOffset*8;
        int xOffset = aRegion.x - origin.x;
        int yOffset = aRegion.y - origin.y;
        dataBitOffset += xOffset*pixelBitStride + yOffset*scanlineStride*8;
        bitMask = (1 << pixelBitStride) -1;
        shiftOffset = 8 - pixelBitStride;
    } else {
        throw new RasterFormatException("BytePackedRasters must have"+
            "MultiPixelPackedSampleModel");
    }
    verify(false);
}
 
源代码20 项目: openjdk-8-source   文件: ByteInterleavedRaster.java
/**
 * Constructs a ByteInterleavedRaster with the given SampleModel,
 * DataBuffer, and parent.  DataBuffer must be a DataBufferByte and
 * SampleModel must be of type SinglePixelPackedSampleModel
 * or InterleavedSampleModel.
 * 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 DataBufferShort 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 ByteInterleavedRaster(SampleModel sampleModel,
                              DataBuffer dataBuffer,
                              Rectangle aRegion,
                              Point origin,
                              ByteInterleavedRaster parent) {
    super(sampleModel, dataBuffer, aRegion, origin, parent);
    this.maxX = minX + width;
    this.maxY = minY + height;

    if (!(dataBuffer instanceof DataBufferByte)) {
        throw new RasterFormatException("ByteInterleavedRasters must have " +
                                        "byte DataBuffers");
    }

    DataBufferByte dbb = (DataBufferByte)dataBuffer;
    this.data = stealData(dbb, 0);

    int xOffset = aRegion.x - origin.x;
    int yOffset = aRegion.y - origin.y;
    if (sampleModel instanceof PixelInterleavedSampleModel ||
        (sampleModel instanceof ComponentSampleModel &&
         isInterleaved((ComponentSampleModel)sampleModel))) {
        ComponentSampleModel csm = (ComponentSampleModel)sampleModel;
        this.scanlineStride = csm.getScanlineStride();
        this.pixelStride = csm.getPixelStride();
        this.dataOffsets = csm.getBandOffsets();
        for (int i = 0; i < getNumDataElements(); i++) {
            dataOffsets[i] += xOffset*pixelStride+yOffset*scanlineStride;
        }
    } else if (sampleModel instanceof SinglePixelPackedSampleModel) {
        SinglePixelPackedSampleModel sppsm =
                (SinglePixelPackedSampleModel)sampleModel;
        this.packed = true;
        this.bitMasks = sppsm.getBitMasks();
        this.bitOffsets = sppsm.getBitOffsets();
        this.scanlineStride = sppsm.getScanlineStride();
        this.pixelStride = 1;
        this.dataOffsets = new int[1];
        this.dataOffsets[0] = dbb.getOffset();
        dataOffsets[0] += xOffset*pixelStride+yOffset*scanlineStride;
    } else {
        throw new RasterFormatException("ByteInterleavedRasters must " +
          "have PixelInterleavedSampleModel, SinglePixelPackedSampleModel"+
          " or interleaved ComponentSampleModel.  Sample model is " +
          sampleModel);
    }
    this.bandOffset = this.dataOffsets[0];

    this.dbOffsetPacked = dataBuffer.getOffset() -
        sampleModelTranslateY*scanlineStride -
        sampleModelTranslateX*pixelStride;
    this.dbOffset = dbOffsetPacked -
        (xOffset*pixelStride+yOffset*scanlineStride);

    // Set inOrder to true if the data elements are in order and
    // have no gaps between them
    this.inOrder = false;
    if (numDataElements == pixelStride) {
        inOrder = true;
        for (int i = 1; i < numDataElements; i++) {
            if (dataOffsets[i] - dataOffsets[0] != i) {
                inOrder = false;
                break;
            }
        }
    }

    verify();
}