Java Code Examples for java.awt.image.DataBufferInt#getOffset()

The following examples show how to use java.awt.image.DataBufferInt#getOffset() . 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: IntegerInterleavedRaster.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a IntegerInterleavedRaster with the given SampleModel,
 * DataBuffer, and parent.  DataBuffer must be a DataBufferInt and
 * SampleModel must be of type SinglePixelPackedSampleModel.
 * When translated into the base Raster's
 * coordinate system, aRegion must be contained by the base Raster.
 * Origin is the coodinate 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 DataBufferInt 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 IntegerInterleavedRaster(SampleModel sampleModel,
                                 DataBuffer dataBuffer,
                                 Rectangle aRegion,
                                 Point origin,
                                 IntegerInterleavedRaster parent){
    super(sampleModel,dataBuffer,aRegion,origin,parent);
    this.maxX = minX + width;
    this.maxY = minY + height;
    if (!(dataBuffer instanceof DataBufferInt)) {
       throw new RasterFormatException("IntegerInterleavedRasters must have" +
            "integer DataBuffers");
    }
    DataBufferInt dbi = (DataBufferInt)dataBuffer;
    this.data = stealData(dbi, 0);

    if (sampleModel instanceof SinglePixelPackedSampleModel) {
        SinglePixelPackedSampleModel sppsm =
                (SinglePixelPackedSampleModel)sampleModel;
        this.scanlineStride = sppsm.getScanlineStride();
        this.pixelStride    = 1;
        this.dataOffsets = new int[1];
        this.dataOffsets[0] = dbi.getOffset();
        this.bandOffset = this.dataOffsets[0];
        int xOffset = aRegion.x - origin.x;
        int yOffset = aRegion.y - origin.y;
        dataOffsets[0] += xOffset+yOffset*scanlineStride;
        this.numDataElems = sppsm.getNumDataElements();
    } else {
        throw new RasterFormatException("IntegerInterleavedRasters must have"+
                                        " SinglePixelPackedSampleModel");
    }
    verify();
}
 
Example 2
Source File: IntegerInterleavedRaster.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a IntegerInterleavedRaster with the given SampleModel,
 * DataBuffer, and parent.  DataBuffer must be a DataBufferInt and
 * SampleModel must be of type SinglePixelPackedSampleModel.
 * When translated into the base Raster's
 * coordinate system, aRegion must be contained by the base Raster.
 * Origin is the coodinate 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 DataBufferInt 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 IntegerInterleavedRaster(SampleModel sampleModel,
                                 DataBuffer dataBuffer,
                                 Rectangle aRegion,
                                 Point origin,
                                 IntegerInterleavedRaster parent){
    super(sampleModel,dataBuffer,aRegion,origin,parent);
    this.maxX = minX + width;
    this.maxY = minY + height;
    if (!(dataBuffer instanceof DataBufferInt)) {
       throw new RasterFormatException("IntegerInterleavedRasters must have" +
            "integer DataBuffers");
    }
    DataBufferInt dbi = (DataBufferInt)dataBuffer;
    this.data = stealData(dbi, 0);

    if (sampleModel instanceof SinglePixelPackedSampleModel) {
        SinglePixelPackedSampleModel sppsm =
                (SinglePixelPackedSampleModel)sampleModel;
        this.scanlineStride = sppsm.getScanlineStride();
        this.pixelStride    = 1;
        this.dataOffsets = new int[1];
        this.dataOffsets[0] = dbi.getOffset();
        this.bandOffset = this.dataOffsets[0];
        int xOffset = aRegion.x - origin.x;
        int yOffset = aRegion.y - origin.y;
        dataOffsets[0] += xOffset+yOffset*scanlineStride;
        this.numDataElems = sppsm.getNumDataElements();
    } else {
        throw new RasterFormatException("IntegerInterleavedRasters must have"+
                                        " SinglePixelPackedSampleModel");
    }
    verify();
}
 
Example 3
Source File: MultipleGradientPaintContext.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public final Raster getRaster(int x, int y, int w, int h) {
    // If working raster is big enough, reuse it. Otherwise,
    // build a large enough new one.
    Raster raster = saved;
    if (raster == null ||
        raster.getWidth() < w || raster.getHeight() < h)
    {
        raster = getCachedRaster(model, w, h);
        saved = raster;
    }

    // Access raster internal int array. Because we use a DirectColorModel,
    // we know the DataBuffer is of type DataBufferInt and the SampleModel
    // is SinglePixelPackedSampleModel.
    // Adjust for initial offset in DataBuffer and also for the scanline
    // stride.
    // These calls make the DataBuffer non-acceleratable, but the
    // Raster is never Stable long enough to accelerate anyway...
    DataBufferInt rasterDB = (DataBufferInt)raster.getDataBuffer();
    int[] pixels = rasterDB.getData(0);
    int off = rasterDB.getOffset();
    int scanlineStride = ((SinglePixelPackedSampleModel)
                          raster.getSampleModel()).getScanlineStride();
    int adjust = scanlineStride - w;

    fillRaster(pixels, off, adjust, x, y, w, h); // delegate to subclass

    return raster;
}
 
Example 4
Source File: CustomCompositeTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void compose(Raster src, Raster dstIn, WritableRaster dstOut) {
    int w = src.getWidth();
    int h = src.getHeight();

    DataBufferInt srcDB = (DataBufferInt) src.getDataBuffer();
    DataBufferInt dstOutDB = (DataBufferInt) dstOut.getDataBuffer();
    int srcRGB[] = srcDB.getBankData()[0];
    int dstOutRGB[] = dstOutDB.getBankData()[0];
    int srcOffset = srcDB.getOffset();
    int dstOutOffset = dstOutDB.getOffset();
    int srcScanStride = ((SinglePixelPackedSampleModel) src.getSampleModel()).getScanlineStride();
    int dstOutScanStride = ((SinglePixelPackedSampleModel) dstOut.getSampleModel()).getScanlineStride();
    int srcAdjust = srcScanStride - w;
    int dstOutAdjust = dstOutScanStride - w;

    int si = srcOffset;
    int doi = dstOutOffset;

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            dstOutRGB[doi] = srcRGB[si] ^ 0x00ffffff;
            si++;
            doi++;
        }

        si += srcAdjust;
        doi += dstOutAdjust;
    }
}
 
Example 5
Source File: MultipleGradientPaintContext.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public final Raster getRaster(int x, int y, int w, int h) {
    // If working raster is big enough, reuse it. Otherwise,
    // build a large enough new one.
    Raster raster = saved;
    if (raster == null ||
        raster.getWidth() < w || raster.getHeight() < h)
    {
        raster = getCachedRaster(model, w, h);
        saved = raster;
    }

    // Access raster internal int array. Because we use a DirectColorModel,
    // we know the DataBuffer is of type DataBufferInt and the SampleModel
    // is SinglePixelPackedSampleModel.
    // Adjust for initial offset in DataBuffer and also for the scanline
    // stride.
    // These calls make the DataBuffer non-acceleratable, but the
    // Raster is never Stable long enough to accelerate anyway...
    DataBufferInt rasterDB = (DataBufferInt)raster.getDataBuffer();
    int[] pixels = rasterDB.getData(0);
    int off = rasterDB.getOffset();
    int scanlineStride = ((SinglePixelPackedSampleModel)
                          raster.getSampleModel()).getScanlineStride();
    int adjust = scanlineStride - w;

    fillRaster(pixels, off, adjust, x, y, w, h); // delegate to subclass

    return raster;
}
 
Example 6
Source File: MultipleGradientPaintContext.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public final Raster getRaster(int x, int y, int w, int h) {
    // If working raster is big enough, reuse it. Otherwise,
    // build a large enough new one.
    Raster raster = saved;
    if (raster == null ||
        raster.getWidth() < w || raster.getHeight() < h)
    {
        raster = getCachedRaster(model, w, h);
        saved = raster;
    }

    // Access raster internal int array. Because we use a DirectColorModel,
    // we know the DataBuffer is of type DataBufferInt and the SampleModel
    // is SinglePixelPackedSampleModel.
    // Adjust for initial offset in DataBuffer and also for the scanline
    // stride.
    // These calls make the DataBuffer non-acceleratable, but the
    // Raster is never Stable long enough to accelerate anyway...
    DataBufferInt rasterDB = (DataBufferInt)raster.getDataBuffer();
    int[] pixels = rasterDB.getData(0);
    int off = rasterDB.getOffset();
    int scanlineStride = ((SinglePixelPackedSampleModel)
                          raster.getSampleModel()).getScanlineStride();
    int adjust = scanlineStride - w;

    fillRaster(pixels, off, adjust, x, y, w, h); // delegate to subclass

    return raster;
}
 
Example 7
Source File: IntegerInterleavedRaster.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a IntegerInterleavedRaster with the given SampleModel,
 * DataBuffer, and parent.  DataBuffer must be a DataBufferInt and
 * SampleModel must be of type SinglePixelPackedSampleModel.
 * When translated into the base Raster's
 * coordinate system, aRegion must be contained by the base Raster.
 * Origin is the coodinate 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 DataBufferInt 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 IntegerInterleavedRaster(SampleModel sampleModel,
                                 DataBuffer dataBuffer,
                                 Rectangle aRegion,
                                 Point origin,
                                 IntegerInterleavedRaster parent){
    super(sampleModel,dataBuffer,aRegion,origin,parent);
    this.maxX = minX + width;
    this.maxY = minY + height;
    if (!(dataBuffer instanceof DataBufferInt)) {
       throw new RasterFormatException("IntegerInterleavedRasters must have" +
            "integer DataBuffers");
    }
    DataBufferInt dbi = (DataBufferInt)dataBuffer;
    this.data = stealData(dbi, 0);

    if (sampleModel instanceof SinglePixelPackedSampleModel) {
        SinglePixelPackedSampleModel sppsm =
                (SinglePixelPackedSampleModel)sampleModel;
        this.scanlineStride = sppsm.getScanlineStride();
        this.pixelStride    = 1;
        this.dataOffsets = new int[1];
        this.dataOffsets[0] = dbi.getOffset();
        this.bandOffset = this.dataOffsets[0];
        int xOffset = aRegion.x - origin.x;
        int yOffset = aRegion.y - origin.y;
        dataOffsets[0] += xOffset+yOffset*scanlineStride;
        this.numDataElems = sppsm.getNumDataElements();
    } else {
        throw new RasterFormatException("IntegerInterleavedRasters must have"+
                                        " SinglePixelPackedSampleModel");
    }
    verify();
}
 
Example 8
Source File: IntegerInterleavedRaster.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a IntegerInterleavedRaster with the given SampleModel,
 * DataBuffer, and parent.  DataBuffer must be a DataBufferInt and
 * SampleModel must be of type SinglePixelPackedSampleModel.
 * When translated into the base Raster's
 * coordinate system, aRegion must be contained by the base Raster.
 * Origin is the coodinate 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 DataBufferInt 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 IntegerInterleavedRaster(SampleModel sampleModel,
                                 DataBuffer dataBuffer,
                                 Rectangle aRegion,
                                 Point origin,
                                 IntegerInterleavedRaster parent){
    super(sampleModel,dataBuffer,aRegion,origin,parent);
    this.maxX = minX + width;
    this.maxY = minY + height;
    if (!(dataBuffer instanceof DataBufferInt)) {
       throw new RasterFormatException("IntegerInterleavedRasters must have" +
            "integer DataBuffers");
    }
    DataBufferInt dbi = (DataBufferInt)dataBuffer;
    this.data = stealData(dbi, 0);

    if (sampleModel instanceof SinglePixelPackedSampleModel) {
        SinglePixelPackedSampleModel sppsm =
                (SinglePixelPackedSampleModel)sampleModel;
        this.scanlineStride = sppsm.getScanlineStride();
        this.pixelStride    = 1;
        this.dataOffsets = new int[1];
        this.dataOffsets[0] = dbi.getOffset();
        this.bandOffset = this.dataOffsets[0];
        int xOffset = aRegion.x - origin.x;
        int yOffset = aRegion.y - origin.y;
        dataOffsets[0] += xOffset+yOffset*scanlineStride;
        this.numDataElems = sppsm.getNumDataElements();
    } else {
        throw new RasterFormatException("IntegerInterleavedRasters must have"+
                                        " SinglePixelPackedSampleModel");
    }
    verify();
}
 
Example 9
Source File: CustomCompositeTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void compose(Raster src, Raster dstIn, WritableRaster dstOut) {
    int w = src.getWidth();
    int h = src.getHeight();

    DataBufferInt srcDB = (DataBufferInt) src.getDataBuffer();
    DataBufferInt dstOutDB = (DataBufferInt) dstOut.getDataBuffer();
    int srcRGB[] = srcDB.getBankData()[0];
    int dstOutRGB[] = dstOutDB.getBankData()[0];
    int srcOffset = srcDB.getOffset();
    int dstOutOffset = dstOutDB.getOffset();
    int srcScanStride = ((SinglePixelPackedSampleModel) src.getSampleModel()).getScanlineStride();
    int dstOutScanStride = ((SinglePixelPackedSampleModel) dstOut.getSampleModel()).getScanlineStride();
    int srcAdjust = srcScanStride - w;
    int dstOutAdjust = dstOutScanStride - w;

    int si = srcOffset;
    int doi = dstOutOffset;

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            dstOutRGB[doi] = srcRGB[si] ^ 0x00ffffff;
            si++;
            doi++;
        }

        si += srcAdjust;
        doi += dstOutAdjust;
    }
}
 
Example 10
Source File: IntegerInterleavedRaster.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a IntegerInterleavedRaster with the given SampleModel,
 * DataBuffer, and parent.  DataBuffer must be a DataBufferInt and
 * SampleModel must be of type SinglePixelPackedSampleModel.
 * When translated into the base Raster's
 * coordinate system, aRegion must be contained by the base Raster.
 * Origin is the coodinate 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 DataBufferInt 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 IntegerInterleavedRaster(SampleModel sampleModel,
                                 DataBuffer dataBuffer,
                                 Rectangle aRegion,
                                 Point origin,
                                 IntegerInterleavedRaster parent){
    super(sampleModel,dataBuffer,aRegion,origin,parent);
    this.maxX = minX + width;
    this.maxY = minY + height;
    if (!(dataBuffer instanceof DataBufferInt)) {
       throw new RasterFormatException("IntegerInterleavedRasters must have" +
            "integer DataBuffers");
    }
    DataBufferInt dbi = (DataBufferInt)dataBuffer;
    this.data = stealData(dbi, 0);

    if (sampleModel instanceof SinglePixelPackedSampleModel) {
        SinglePixelPackedSampleModel sppsm =
                (SinglePixelPackedSampleModel)sampleModel;
        this.scanlineStride = sppsm.getScanlineStride();
        this.pixelStride    = 1;
        this.dataOffsets = new int[1];
        this.dataOffsets[0] = dbi.getOffset();
        this.bandOffset = this.dataOffsets[0];
        int xOffset = aRegion.x - origin.x;
        int yOffset = aRegion.y - origin.y;
        dataOffsets[0] += xOffset+yOffset*scanlineStride;
        this.numDataElems = sppsm.getNumDataElements();
    } else {
        throw new RasterFormatException("IntegerInterleavedRasters must have"+
                                        " SinglePixelPackedSampleModel");
    }
    verify();
}
 
Example 11
Source File: IntegerInterleavedRaster.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a IntegerInterleavedRaster with the given SampleModel,
 * DataBuffer, and parent.  DataBuffer must be a DataBufferInt and
 * SampleModel must be of type SinglePixelPackedSampleModel.
 * When translated into the base Raster's
 * coordinate system, aRegion must be contained by the base Raster.
 * Origin is the coodinate 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 DataBufferInt 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 IntegerInterleavedRaster(SampleModel sampleModel,
                                 DataBuffer dataBuffer,
                                 Rectangle aRegion,
                                 Point origin,
                                 IntegerInterleavedRaster parent){
    super(sampleModel,dataBuffer,aRegion,origin,parent);
    this.maxX = minX + width;
    this.maxY = minY + height;
    if (!(dataBuffer instanceof DataBufferInt)) {
       throw new RasterFormatException("IntegerInterleavedRasters must have" +
            "integer DataBuffers");
    }
    DataBufferInt dbi = (DataBufferInt)dataBuffer;
    this.data = stealData(dbi, 0);

    if (sampleModel instanceof SinglePixelPackedSampleModel) {
        SinglePixelPackedSampleModel sppsm =
                (SinglePixelPackedSampleModel)sampleModel;
        this.scanlineStride = sppsm.getScanlineStride();
        this.pixelStride    = 1;
        this.dataOffsets = new int[1];
        this.dataOffsets[0] = dbi.getOffset();
        this.bandOffset = this.dataOffsets[0];
        int xOffset = aRegion.x - origin.x;
        int yOffset = aRegion.y - origin.y;
        dataOffsets[0] += xOffset+yOffset*scanlineStride;
        this.numDataElems = sppsm.getNumDataElements();
    } else {
        throw new RasterFormatException("IntegerInterleavedRasters must have"+
                                        " SinglePixelPackedSampleModel");
    }
    verify();
}
 
Example 12
Source File: CustomCompositeTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void compose(Raster src, Raster dstIn, WritableRaster dstOut) {
    int w = src.getWidth();
    int h = src.getHeight();

    DataBufferInt srcDB = (DataBufferInt) src.getDataBuffer();
    DataBufferInt dstOutDB = (DataBufferInt) dstOut.getDataBuffer();
    int srcRGB[] = srcDB.getBankData()[0];
    int dstOutRGB[] = dstOutDB.getBankData()[0];
    int srcOffset = srcDB.getOffset();
    int dstOutOffset = dstOutDB.getOffset();
    int srcScanStride = ((SinglePixelPackedSampleModel) src.getSampleModel()).getScanlineStride();
    int dstOutScanStride = ((SinglePixelPackedSampleModel) dstOut.getSampleModel()).getScanlineStride();
    int srcAdjust = srcScanStride - w;
    int dstOutAdjust = dstOutScanStride - w;

    int si = srcOffset;
    int doi = dstOutOffset;

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            dstOutRGB[doi] = srcRGB[si] ^ 0x00ffffff;
            si++;
            doi++;
        }

        si += srcAdjust;
        doi += dstOutAdjust;
    }
}
 
Example 13
Source File: MultipleGradientPaintContext.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public final Raster getRaster(int x, int y, int w, int h) {
    // If working raster is big enough, reuse it. Otherwise,
    // build a large enough new one.
    Raster raster = saved;
    if (raster == null ||
        raster.getWidth() < w || raster.getHeight() < h)
    {
        raster = getCachedRaster(model, w, h);
        saved = raster;
    }

    // Access raster internal int array. Because we use a DirectColorModel,
    // we know the DataBuffer is of type DataBufferInt and the SampleModel
    // is SinglePixelPackedSampleModel.
    // Adjust for initial offset in DataBuffer and also for the scanline
    // stride.
    // These calls make the DataBuffer non-acceleratable, but the
    // Raster is never Stable long enough to accelerate anyway...
    DataBufferInt rasterDB = (DataBufferInt)raster.getDataBuffer();
    int[] pixels = rasterDB.getData(0);
    int off = rasterDB.getOffset();
    int scanlineStride = ((SinglePixelPackedSampleModel)
                          raster.getSampleModel()).getScanlineStride();
    int adjust = scanlineStride - w;

    fillRaster(pixels, off, adjust, x, y, w, h); // delegate to subclass

    return raster;
}
 
Example 14
Source File: IntegerInterleavedRaster.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a IntegerInterleavedRaster with the given SampleModel,
 * DataBuffer, and parent.  DataBuffer must be a DataBufferInt and
 * SampleModel must be of type SinglePixelPackedSampleModel.
 * When translated into the base Raster's
 * coordinate system, aRegion must be contained by the base Raster.
 * Origin is the coodinate 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 DataBufferInt 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 IntegerInterleavedRaster(SampleModel sampleModel,
                                 DataBuffer dataBuffer,
                                 Rectangle aRegion,
                                 Point origin,
                                 IntegerInterleavedRaster parent){
    super(sampleModel,dataBuffer,aRegion,origin,parent);
    this.maxX = minX + width;
    this.maxY = minY + height;
    if (!(dataBuffer instanceof DataBufferInt)) {
       throw new RasterFormatException("IntegerInterleavedRasters must have" +
            "integer DataBuffers");
    }
    DataBufferInt dbi = (DataBufferInt)dataBuffer;
    this.data = stealData(dbi, 0);

    if (sampleModel instanceof SinglePixelPackedSampleModel) {
        SinglePixelPackedSampleModel sppsm =
                (SinglePixelPackedSampleModel)sampleModel;
        this.scanlineStride = sppsm.getScanlineStride();
        this.pixelStride    = 1;
        this.dataOffsets = new int[1];
        this.dataOffsets[0] = dbi.getOffset();
        this.bandOffset = this.dataOffsets[0];
        int xOffset = aRegion.x - origin.x;
        int yOffset = aRegion.y - origin.y;
        dataOffsets[0] += xOffset+yOffset*scanlineStride;
        this.numDataElems = sppsm.getNumDataElements();
    } else {
        throw new RasterFormatException("IntegerInterleavedRasters must have"+
                                        " SinglePixelPackedSampleModel");
    }
    verify();
}
 
Example 15
Source File: IntegerInterleavedRaster.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a IntegerInterleavedRaster with the given SampleModel,
 * DataBuffer, and parent.  DataBuffer must be a DataBufferInt and
 * SampleModel must be of type SinglePixelPackedSampleModel.
 * When translated into the base Raster's
 * coordinate system, aRegion must be contained by the base Raster.
 * Origin is the coodinate 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 DataBufferInt 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 IntegerInterleavedRaster(SampleModel sampleModel,
                                DataBufferInt dataBuffer,
                                Rectangle aRegion,
                                Point origin,
                                IntegerInterleavedRaster parent)
{
    super(sampleModel,dataBuffer,aRegion,origin,parent);
    this.maxX = minX + width;
    this.maxY = minY + height;

    this.data = stealData(dataBuffer, 0);

    if (sampleModel instanceof SinglePixelPackedSampleModel) {
        SinglePixelPackedSampleModel sppsm =
                (SinglePixelPackedSampleModel)sampleModel;
        this.scanlineStride = sppsm.getScanlineStride();
        this.pixelStride    = 1;
        this.dataOffsets = new int[1];
        this.dataOffsets[0] = dataBuffer.getOffset();
        this.bandOffset = this.dataOffsets[0];
        int xOffset = aRegion.x - origin.x;
        int yOffset = aRegion.y - origin.y;
        dataOffsets[0] += xOffset+yOffset*scanlineStride;
        this.numDataElems = sppsm.getNumDataElements();
    } else {
        throw new RasterFormatException("IntegerInterleavedRasters must have"+
                                        " SinglePixelPackedSampleModel");
    }
    verify();
}
 
Example 16
Source File: IntegerComponentRaster.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * Constructs a IntegerComponentRaster with the given SampleModel,
 * DataBuffer, and parent.  DataBuffer must be a DataBufferInt and
 * SampleModel must be of type SinglePixelPackedSampleModel.
 * When translated into the base Raster's
 * coordinate system, aRegion must be contained by the base Raster.
 * Origin is the coodinate 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 DataBufferInt 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 IntegerComponentRaster(SampleModel sampleModel,
                              DataBufferInt dataBuffer,
                              Rectangle aRegion,
                              Point origin,
                              IntegerComponentRaster parent)
{
    super(sampleModel,dataBuffer,aRegion,origin,parent);
    this.maxX = minX + width;
    this.maxY = minY + height;

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

    if (sampleModel instanceof SinglePixelPackedSampleModel) {
        SinglePixelPackedSampleModel sppsm =
                (SinglePixelPackedSampleModel)sampleModel;
        int[] boffsets = sppsm.getBitOffsets();
        boolean notByteBoundary = false;
        for (int i=1; i < boffsets.length; i++) {
            if ((boffsets[i]%8) != 0) {
                notByteBoundary = true;
            }
        }
        this.type = (notByteBoundary
                     ? IntegerComponentRaster.TYPE_INT_PACKED_SAMPLES
                     : IntegerComponentRaster.TYPE_INT_8BIT_SAMPLES);

        this.scanlineStride = sppsm.getScanlineStride();
        this.pixelStride    = 1;
        this.dataOffsets = new int[1];
        this.dataOffsets[0] = dataBuffer.getOffset();
        this.bandOffset = this.dataOffsets[0];
        int xOffset = aRegion.x - origin.x;
        int yOffset = aRegion.y - origin.y;
        dataOffsets[0] += xOffset+yOffset*scanlineStride;
        this.numDataElems = sppsm.getNumDataElements();
    } else {
        throw new RasterFormatException("IntegerComponentRasters must have"+
                                        " SinglePixelPackedSampleModel");
    }

    verify();
}
 
Example 17
Source File: IntegerComponentRaster.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructs a IntegerComponentRaster with the given SampleModel,
 * DataBuffer, and parent.  DataBuffer must be a DataBufferInt and
 * SampleModel must be of type SinglePixelPackedSampleModel.
 * When translated into the base Raster's
 * coordinate system, aRegion must be contained by the base Raster.
 * Origin is the coodinate 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 DataBufferInt 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 IntegerComponentRaster(SampleModel sampleModel,
                                 DataBuffer dataBuffer,
                                 Rectangle aRegion,
                                 Point origin,
                                 IntegerComponentRaster parent){
    super(sampleModel,dataBuffer,aRegion,origin,parent);
    this.maxX = minX + width;
    this.maxY = minY + height;
    if (!(dataBuffer instanceof DataBufferInt)) {
       throw new RasterFormatException("IntegerComponentRasters must have" +
            "integer DataBuffers");
    }
    DataBufferInt dbi = (DataBufferInt)dataBuffer;
    if (dbi.getNumBanks() != 1) {
        throw new
            RasterFormatException("DataBuffer for IntegerComponentRasters"+
                                  " must only have 1 bank.");
    }
    this.data = stealData(dbi, 0);

    if (sampleModel instanceof SinglePixelPackedSampleModel) {
        SinglePixelPackedSampleModel sppsm =
                (SinglePixelPackedSampleModel)sampleModel;
        int[] boffsets = sppsm.getBitOffsets();
        boolean notByteBoundary = false;
        for (int i=1; i < boffsets.length; i++) {
            if ((boffsets[i]%8) != 0) {
                notByteBoundary = true;
            }
        }
        this.type = (notByteBoundary
                     ? IntegerComponentRaster.TYPE_INT_PACKED_SAMPLES
                     : IntegerComponentRaster.TYPE_INT_8BIT_SAMPLES);

        this.scanlineStride = sppsm.getScanlineStride();
        this.pixelStride    = 1;
        this.dataOffsets = new int[1];
        this.dataOffsets[0] = dbi.getOffset();
        this.bandOffset = this.dataOffsets[0];
        int xOffset = aRegion.x - origin.x;
        int yOffset = aRegion.y - origin.y;
        dataOffsets[0] += xOffset+yOffset*scanlineStride;
        this.numDataElems = sppsm.getNumDataElements();
    } else {
        throw new RasterFormatException("IntegerComponentRasters must have"+
                                        " SinglePixelPackedSampleModel");
    }

    verify();
}
 
Example 18
Source File: IntegerComponentRaster.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructs a IntegerComponentRaster with the given SampleModel,
 * DataBuffer, and parent.  DataBuffer must be a DataBufferInt and
 * SampleModel must be of type SinglePixelPackedSampleModel.
 * When translated into the base Raster's
 * coordinate system, aRegion must be contained by the base Raster.
 * Origin is the coodinate 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 DataBufferInt 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 IntegerComponentRaster(SampleModel sampleModel,
                                 DataBuffer dataBuffer,
                                 Rectangle aRegion,
                                 Point origin,
                                 IntegerComponentRaster parent){
    super(sampleModel,dataBuffer,aRegion,origin,parent);
    this.maxX = minX + width;
    this.maxY = minY + height;
    if (!(dataBuffer instanceof DataBufferInt)) {
       throw new RasterFormatException("IntegerComponentRasters must have" +
            "integer DataBuffers");
    }
    DataBufferInt dbi = (DataBufferInt)dataBuffer;
    if (dbi.getNumBanks() != 1) {
        throw new
            RasterFormatException("DataBuffer for IntegerComponentRasters"+
                                  " must only have 1 bank.");
    }
    this.data = stealData(dbi, 0);

    if (sampleModel instanceof SinglePixelPackedSampleModel) {
        SinglePixelPackedSampleModel sppsm =
                (SinglePixelPackedSampleModel)sampleModel;
        int[] boffsets = sppsm.getBitOffsets();
        boolean notByteBoundary = false;
        for (int i=1; i < boffsets.length; i++) {
            if ((boffsets[i]%8) != 0) {
                notByteBoundary = true;
            }
        }
        this.type = (notByteBoundary
                     ? IntegerComponentRaster.TYPE_INT_PACKED_SAMPLES
                     : IntegerComponentRaster.TYPE_INT_8BIT_SAMPLES);

        this.scanlineStride = sppsm.getScanlineStride();
        this.pixelStride    = 1;
        this.dataOffsets = new int[1];
        this.dataOffsets[0] = dbi.getOffset();
        this.bandOffset = this.dataOffsets[0];
        int xOffset = aRegion.x - origin.x;
        int yOffset = aRegion.y - origin.y;
        dataOffsets[0] += xOffset+yOffset*scanlineStride;
        this.numDataElems = sppsm.getNumDataElements();
    } else {
        throw new RasterFormatException("IntegerComponentRasters must have"+
                                        " SinglePixelPackedSampleModel");
    }

    verify();
}
 
Example 19
Source File: IntegerComponentRaster.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructs a IntegerComponentRaster with the given SampleModel,
 * DataBuffer, and parent.  DataBuffer must be a DataBufferInt and
 * SampleModel must be of type SinglePixelPackedSampleModel.
 * When translated into the base Raster's
 * coordinate system, aRegion must be contained by the base Raster.
 * Origin is the coodinate 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 DataBufferInt 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 IntegerComponentRaster(SampleModel sampleModel,
                                 DataBuffer dataBuffer,
                                 Rectangle aRegion,
                                 Point origin,
                                 IntegerComponentRaster parent){
    super(sampleModel,dataBuffer,aRegion,origin,parent);
    this.maxX = minX + width;
    this.maxY = minY + height;
    if (!(dataBuffer instanceof DataBufferInt)) {
       throw new RasterFormatException("IntegerComponentRasters must have" +
            "integer DataBuffers");
    }
    DataBufferInt dbi = (DataBufferInt)dataBuffer;
    if (dbi.getNumBanks() != 1) {
        throw new
            RasterFormatException("DataBuffer for IntegerComponentRasters"+
                                  " must only have 1 bank.");
    }
    this.data = stealData(dbi, 0);

    if (sampleModel instanceof SinglePixelPackedSampleModel) {
        SinglePixelPackedSampleModel sppsm =
                (SinglePixelPackedSampleModel)sampleModel;
        int[] boffsets = sppsm.getBitOffsets();
        boolean notByteBoundary = false;
        for (int i=1; i < boffsets.length; i++) {
            if ((boffsets[i]%8) != 0) {
                notByteBoundary = true;
            }
        }
        this.type = (notByteBoundary
                     ? IntegerComponentRaster.TYPE_INT_PACKED_SAMPLES
                     : IntegerComponentRaster.TYPE_INT_8BIT_SAMPLES);

        this.scanlineStride = sppsm.getScanlineStride();
        this.pixelStride    = 1;
        this.dataOffsets = new int[1];
        this.dataOffsets[0] = dbi.getOffset();
        this.bandOffset = this.dataOffsets[0];
        int xOffset = aRegion.x - origin.x;
        int yOffset = aRegion.y - origin.y;
        dataOffsets[0] += xOffset+yOffset*scanlineStride;
        this.numDataElems = sppsm.getNumDataElements();
    } else {
        throw new RasterFormatException("IntegerComponentRasters must have"+
                                        " SinglePixelPackedSampleModel");
    }

    verify();
}
 
Example 20
Source File: IntegerComponentRaster.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructs a IntegerComponentRaster with the given SampleModel,
 * DataBuffer, and parent.  DataBuffer must be a DataBufferInt and
 * SampleModel must be of type SinglePixelPackedSampleModel.
 * When translated into the base Raster's
 * coordinate system, aRegion must be contained by the base Raster.
 * Origin is the coodinate 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 DataBufferInt 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 IntegerComponentRaster(SampleModel sampleModel,
                                 DataBuffer dataBuffer,
                                 Rectangle aRegion,
                                 Point origin,
                                 IntegerComponentRaster parent){
    super(sampleModel,dataBuffer,aRegion,origin,parent);
    this.maxX = minX + width;
    this.maxY = minY + height;
    if (!(dataBuffer instanceof DataBufferInt)) {
       throw new RasterFormatException("IntegerComponentRasters must have" +
            "integer DataBuffers");
    }
    DataBufferInt dbi = (DataBufferInt)dataBuffer;
    if (dbi.getNumBanks() != 1) {
        throw new
            RasterFormatException("DataBuffer for IntegerComponentRasters"+
                                  " must only have 1 bank.");
    }
    this.data = stealData(dbi, 0);

    if (sampleModel instanceof SinglePixelPackedSampleModel) {
        SinglePixelPackedSampleModel sppsm =
                (SinglePixelPackedSampleModel)sampleModel;
        int[] boffsets = sppsm.getBitOffsets();
        boolean notByteBoundary = false;
        for (int i=1; i < boffsets.length; i++) {
            if ((boffsets[i]%8) != 0) {
                notByteBoundary = true;
            }
        }
        this.type = (notByteBoundary
                     ? IntegerComponentRaster.TYPE_INT_PACKED_SAMPLES
                     : IntegerComponentRaster.TYPE_INT_8BIT_SAMPLES);

        this.scanlineStride = sppsm.getScanlineStride();
        this.pixelStride    = 1;
        this.dataOffsets = new int[1];
        this.dataOffsets[0] = dbi.getOffset();
        this.bandOffset = this.dataOffsets[0];
        int xOffset = aRegion.x - origin.x;
        int yOffset = aRegion.y - origin.y;
        dataOffsets[0] += xOffset+yOffset*scanlineStride;
        this.numDataElems = sppsm.getNumDataElements();
    } else {
        throw new RasterFormatException("IntegerComponentRasters must have"+
                                        " SinglePixelPackedSampleModel");
    }

    verify();
}