Java Code Examples for java.awt.image.DataBufferByte#getOffsets()

The following examples show how to use java.awt.image.DataBufferByte#getOffsets() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ByteBandedRaster.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 *  Constructs a ByteBandedRaster with the given sampleModel,
 *  DataBuffer, and parent. DataBuffer must be a DataBufferShort 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 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 ByteBandedRaster(SampleModel sampleModel,
                        DataBuffer dataBuffer,
                        Rectangle aRegion,
                        Point origin,
                        ByteBandedRaster parent) {

    super(sampleModel, dataBuffer, aRegion, origin, parent);
    this.maxX = minX + width;
    this.maxY = minY + height;

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

    if (sampleModel instanceof BandedSampleModel) {
        BandedSampleModel bsm = (BandedSampleModel)sampleModel;
        this.scanlineStride = bsm.getScanlineStride();
        int bankIndices[] = bsm.getBankIndices();
        int bandOffsets[] = bsm.getBandOffsets();
        int dOffsets[] = dbb.getOffsets();
        dataOffsets = new int[bankIndices.length];
        data = new byte[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(dbb, bankIndices[i]);
           dataOffsets[i] = dOffsets[bankIndices[i]] +
               xOffset + yOffset*scanlineStride + bandOffsets[i];
        }
    } else {
        throw new RasterFormatException("ByteBandedRasters must have"+
            "BandedSampleModels");
    }
    verify();
}
 
Example 2
Source File: ByteBandedRaster.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 *  Constructs a ByteBandedRaster with the given sampleModel,
 *  DataBuffer, and parent. DataBuffer must be a DataBufferShort 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 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 ByteBandedRaster(SampleModel sampleModel,
                        DataBuffer dataBuffer,
                        Rectangle aRegion,
                        Point origin,
                        ByteBandedRaster parent) {

    super(sampleModel, dataBuffer, aRegion, origin, parent);
    this.maxX = minX + width;
    this.maxY = minY + height;

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

    if (sampleModel instanceof BandedSampleModel) {
        BandedSampleModel bsm = (BandedSampleModel)sampleModel;
        this.scanlineStride = bsm.getScanlineStride();
        int bankIndices[] = bsm.getBankIndices();
        int bandOffsets[] = bsm.getBandOffsets();
        int dOffsets[] = dbb.getOffsets();
        dataOffsets = new int[bankIndices.length];
        data = new byte[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(dbb, bankIndices[i]);
           dataOffsets[i] = dOffsets[bankIndices[i]] +
               xOffset + yOffset*scanlineStride + bandOffsets[i];
        }
    } else {
        throw new RasterFormatException("ByteBandedRasters must have"+
            "BandedSampleModels");
    }
    verify();
}
 
Example 3
Source File: ByteBandedRaster.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 *  Constructs a ByteBandedRaster with the given sampleModel,
 *  DataBuffer, and parent. DataBuffer must be a DataBufferShort 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 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 ByteBandedRaster(SampleModel sampleModel,
                        DataBuffer dataBuffer,
                        Rectangle aRegion,
                        Point origin,
                        ByteBandedRaster parent) {

    super(sampleModel, dataBuffer, aRegion, origin, parent);
    this.maxX = minX + width;
    this.maxY = minY + height;

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

    if (sampleModel instanceof BandedSampleModel) {
        BandedSampleModel bsm = (BandedSampleModel)sampleModel;
        this.scanlineStride = bsm.getScanlineStride();
        int bankIndices[] = bsm.getBankIndices();
        int bandOffsets[] = bsm.getBandOffsets();
        int dOffsets[] = dbb.getOffsets();
        dataOffsets = new int[bankIndices.length];
        data = new byte[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(dbb, bankIndices[i]);
           dataOffsets[i] = dOffsets[bankIndices[i]] +
               xOffset + yOffset*scanlineStride + bandOffsets[i];
        }
    } else {
        throw new RasterFormatException("ByteBandedRasters must have"+
            "BandedSampleModels");
    }
    verify();
}
 
Example 4
Source File: ByteBandedRaster.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 *  Constructs a ByteBandedRaster with the given sampleModel,
 *  DataBuffer, and parent. DataBuffer must be a DataBufferShort 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 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 ByteBandedRaster(SampleModel sampleModel,
                        DataBuffer dataBuffer,
                        Rectangle aRegion,
                        Point origin,
                        ByteBandedRaster parent) {

    super(sampleModel, dataBuffer, aRegion, origin, parent);
    this.maxX = minX + width;
    this.maxY = minY + height;

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

    if (sampleModel instanceof BandedSampleModel) {
        BandedSampleModel bsm = (BandedSampleModel)sampleModel;
        this.scanlineStride = bsm.getScanlineStride();
        int bankIndices[] = bsm.getBankIndices();
        int bandOffsets[] = bsm.getBandOffsets();
        int dOffsets[] = dbb.getOffsets();
        dataOffsets = new int[bankIndices.length];
        data = new byte[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(dbb, bankIndices[i]);
           dataOffsets[i] = dOffsets[bankIndices[i]] +
               xOffset + yOffset*scanlineStride + bandOffsets[i];
        }
    } else {
        throw new RasterFormatException("ByteBandedRasters must have"+
            "BandedSampleModels");
    }
    verify();
}
 
Example 5
Source File: ByteBandedRaster.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 *  Constructs a ByteBandedRaster with the given sampleModel,
 *  DataBuffer, and parent. DataBuffer must be a DataBufferShort 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 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 ByteBandedRaster(SampleModel sampleModel,
                        DataBuffer dataBuffer,
                        Rectangle aRegion,
                        Point origin,
                        ByteBandedRaster parent) {

    super(sampleModel, dataBuffer, aRegion, origin, parent);
    this.maxX = minX + width;
    this.maxY = minY + height;

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

    if (sampleModel instanceof BandedSampleModel) {
        BandedSampleModel bsm = (BandedSampleModel)sampleModel;
        this.scanlineStride = bsm.getScanlineStride();
        int bankIndices[] = bsm.getBankIndices();
        int bandOffsets[] = bsm.getBandOffsets();
        int dOffsets[] = dbb.getOffsets();
        dataOffsets = new int[bankIndices.length];
        data = new byte[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(dbb, bankIndices[i]);
           dataOffsets[i] = dOffsets[bankIndices[i]] +
               xOffset + yOffset*scanlineStride + bandOffsets[i];
        }
    } else {
        throw new RasterFormatException("ByteBandedRasters must have"+
            "BandedSampleModels");
    }
    verify();
}
 
Example 6
Source File: ByteBandedRaster.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 *  Constructs a ByteBandedRaster with the given sampleModel,
 *  DataBuffer, and parent. DataBuffer must be a DataBufferShort 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 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 ByteBandedRaster(SampleModel sampleModel,
                        DataBufferByte dataBuffer,
                        Rectangle aRegion,
                        Point origin,
                        ByteBandedRaster 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 byte[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("ByteBandedRasters must have"+
            "BandedSampleModels");
    }
    verify();
}
 
Example 7
Source File: ByteBandedRaster.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 *  Constructs a ByteBandedRaster with the given sampleModel,
 *  DataBuffer, and parent. DataBuffer must be a DataBufferShort 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 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 ByteBandedRaster(SampleModel sampleModel,
                        DataBufferByte dataBuffer,
                        Rectangle aRegion,
                        Point origin,
                        ByteBandedRaster 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 byte[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("ByteBandedRasters must have"+
            "BandedSampleModels");
    }
    verify();
}
 
Example 8
Source File: ByteBandedRaster.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 *  Constructs a ByteBandedRaster with the given sampleModel,
 *  DataBuffer, and parent. DataBuffer must be a DataBufferShort 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 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 ByteBandedRaster(SampleModel sampleModel,
                        DataBuffer dataBuffer,
                        Rectangle aRegion,
                        Point origin,
                        ByteBandedRaster parent) {

    super(sampleModel, dataBuffer, aRegion, origin, parent);
    this.maxX = minX + width;
    this.maxY = minY + height;

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

    if (sampleModel instanceof BandedSampleModel) {
        BandedSampleModel bsm = (BandedSampleModel)sampleModel;
        this.scanlineStride = bsm.getScanlineStride();
        int bankIndices[] = bsm.getBankIndices();
        int bandOffsets[] = bsm.getBandOffsets();
        int dOffsets[] = dbb.getOffsets();
        dataOffsets = new int[bankIndices.length];
        data = new byte[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(dbb, bankIndices[i]);
           dataOffsets[i] = dOffsets[bankIndices[i]] +
               xOffset + yOffset*scanlineStride + bandOffsets[i];
        }
    } else {
        throw new RasterFormatException("ByteBandedRasters must have"+
            "BandedSampleModels");
    }
    verify();
}
 
Example 9
Source File: ByteBandedRaster.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 *  Constructs a ByteBandedRaster with the given sampleModel,
 *  DataBuffer, and parent. DataBuffer must be a DataBufferShort 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 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 ByteBandedRaster(SampleModel sampleModel,
                        DataBuffer dataBuffer,
                        Rectangle aRegion,
                        Point origin,
                        ByteBandedRaster parent) {

    super(sampleModel, dataBuffer, aRegion, origin, parent);
    this.maxX = minX + width;
    this.maxY = minY + height;

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

    if (sampleModel instanceof BandedSampleModel) {
        BandedSampleModel bsm = (BandedSampleModel)sampleModel;
        this.scanlineStride = bsm.getScanlineStride();
        int bankIndices[] = bsm.getBankIndices();
        int bandOffsets[] = bsm.getBandOffsets();
        int dOffsets[] = dbb.getOffsets();
        dataOffsets = new int[bankIndices.length];
        data = new byte[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(dbb, bankIndices[i]);
           dataOffsets[i] = dOffsets[bankIndices[i]] +
               xOffset + yOffset*scanlineStride + bandOffsets[i];
        }
    } else {
        throw new RasterFormatException("ByteBandedRasters must have"+
            "BandedSampleModels");
    }
    verify();
}
 
Example 10
Source File: ByteBandedRaster.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 *  Constructs a ByteBandedRaster with the given sampleModel,
 *  DataBuffer, and parent. DataBuffer must be a DataBufferShort 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 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 ByteBandedRaster(SampleModel sampleModel,
                        DataBuffer dataBuffer,
                        Rectangle aRegion,
                        Point origin,
                        ByteBandedRaster parent) {

    super(sampleModel, dataBuffer, aRegion, origin, parent);
    this.maxX = minX + width;
    this.maxY = minY + height;

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

    if (sampleModel instanceof BandedSampleModel) {
        BandedSampleModel bsm = (BandedSampleModel)sampleModel;
        this.scanlineStride = bsm.getScanlineStride();
        int bankIndices[] = bsm.getBankIndices();
        int bandOffsets[] = bsm.getBandOffsets();
        int dOffsets[] = dbb.getOffsets();
        dataOffsets = new int[bankIndices.length];
        data = new byte[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(dbb, bankIndices[i]);
           dataOffsets[i] = dOffsets[bankIndices[i]] +
               xOffset + yOffset*scanlineStride + bandOffsets[i];
        }
    } else {
        throw new RasterFormatException("ByteBandedRasters must have"+
            "BandedSampleModels");
    }
    verify();
}
 
Example 11
Source File: ByteBandedRaster.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 *  Constructs a ByteBandedRaster with the given sampleModel,
 *  DataBuffer, and parent. DataBuffer must be a DataBufferShort 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 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 ByteBandedRaster(SampleModel sampleModel,
                        DataBuffer dataBuffer,
                        Rectangle aRegion,
                        Point origin,
                        ByteBandedRaster parent) {

    super(sampleModel, dataBuffer, aRegion, origin, parent);
    this.maxX = minX + width;
    this.maxY = minY + height;

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

    if (sampleModel instanceof BandedSampleModel) {
        BandedSampleModel bsm = (BandedSampleModel)sampleModel;
        this.scanlineStride = bsm.getScanlineStride();
        int bankIndices[] = bsm.getBankIndices();
        int bandOffsets[] = bsm.getBandOffsets();
        int dOffsets[] = dbb.getOffsets();
        dataOffsets = new int[bankIndices.length];
        data = new byte[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(dbb, bankIndices[i]);
           dataOffsets[i] = dOffsets[bankIndices[i]] +
               xOffset + yOffset*scanlineStride + bandOffsets[i];
        }
    } else {
        throw new RasterFormatException("ByteBandedRasters must have"+
            "BandedSampleModels");
    }
    verify();
}
 
Example 12
Source File: ByteBandedRaster.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 *  Constructs a ByteBandedRaster with the given sampleModel,
 *  DataBuffer, and parent. DataBuffer must be a DataBufferShort 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 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 ByteBandedRaster(SampleModel sampleModel,
                        DataBuffer dataBuffer,
                        Rectangle aRegion,
                        Point origin,
                        ByteBandedRaster parent) {

    super(sampleModel, dataBuffer, aRegion, origin, parent);
    this.maxX = minX + width;
    this.maxY = minY + height;

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

    if (sampleModel instanceof BandedSampleModel) {
        BandedSampleModel bsm = (BandedSampleModel)sampleModel;
        this.scanlineStride = bsm.getScanlineStride();
        int bankIndices[] = bsm.getBankIndices();
        int bandOffsets[] = bsm.getBandOffsets();
        int dOffsets[] = dbb.getOffsets();
        dataOffsets = new int[bankIndices.length];
        data = new byte[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(dbb, bankIndices[i]);
           dataOffsets[i] = dOffsets[bankIndices[i]] +
               xOffset + yOffset*scanlineStride + bandOffsets[i];
        }
    } else {
        throw new RasterFormatException("ByteBandedRasters must have"+
            "BandedSampleModels");
    }
    verify();
}
 
Example 13
Source File: ByteBandedRaster.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 *  Constructs a ByteBandedRaster with the given sampleModel,
 *  DataBuffer, and parent. DataBuffer must be a DataBufferShort 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 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 ByteBandedRaster(SampleModel sampleModel,
                        DataBuffer dataBuffer,
                        Rectangle aRegion,
                        Point origin,
                        ByteBandedRaster parent) {

    super(sampleModel, dataBuffer, aRegion, origin, parent);
    this.maxX = minX + width;
    this.maxY = minY + height;

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

    if (sampleModel instanceof BandedSampleModel) {
        BandedSampleModel bsm = (BandedSampleModel)sampleModel;
        this.scanlineStride = bsm.getScanlineStride();
        int bankIndices[] = bsm.getBankIndices();
        int bandOffsets[] = bsm.getBandOffsets();
        int dOffsets[] = dbb.getOffsets();
        dataOffsets = new int[bankIndices.length];
        data = new byte[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(dbb, bankIndices[i]);
           dataOffsets[i] = dOffsets[bankIndices[i]] +
               xOffset + yOffset*scanlineStride + bandOffsets[i];
        }
    } else {
        throw new RasterFormatException("ByteBandedRasters must have"+
            "BandedSampleModels");
    }
    verify();
}
 
Example 14
Source File: ByteBandedRaster.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 *  Constructs a ByteBandedRaster with the given sampleModel,
 *  DataBuffer, and parent. DataBuffer must be a DataBufferShort 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 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 ByteBandedRaster(SampleModel sampleModel,
                        DataBuffer dataBuffer,
                        Rectangle aRegion,
                        Point origin,
                        ByteBandedRaster parent) {

    super(sampleModel, dataBuffer, aRegion, origin, parent);
    this.maxX = minX + width;
    this.maxY = minY + height;

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

    if (sampleModel instanceof BandedSampleModel) {
        BandedSampleModel bsm = (BandedSampleModel)sampleModel;
        this.scanlineStride = bsm.getScanlineStride();
        int bankIndices[] = bsm.getBankIndices();
        int bandOffsets[] = bsm.getBandOffsets();
        int dOffsets[] = dbb.getOffsets();
        dataOffsets = new int[bankIndices.length];
        data = new byte[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(dbb, bankIndices[i]);
           dataOffsets[i] = dOffsets[bankIndices[i]] +
               xOffset + yOffset*scanlineStride + bandOffsets[i];
        }
    } else {
        throw new RasterFormatException("ByteBandedRasters must have"+
            "BandedSampleModels");
    }
    verify();
}
 
Example 15
Source File: ObjectUtils.java    From WorldPainter with GNU General Public License v3.0 4 votes vote down vote up
public static DataBufferByte clone(DataBufferByte dataBuffer) {
    return new DataBufferByte(clone(dataBuffer.getBankData()), dataBuffer.getSize(), dataBuffer.getOffsets());
}