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

The following examples show how to use java.awt.image.DataBufferByte#getNumBanks() . 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: ImageService.java    From jlineup with Apache License 2.0 5 votes vote down vote up
public static boolean bufferedImagesEqualQuick(BufferedImage image1, BufferedImage image2) {
    DataBuffer dataBuffer1 = image1.getRaster().getDataBuffer();
    DataBuffer dataBuffer2 = image2.getRaster().getDataBuffer();
    if (dataBuffer1 instanceof DataBufferByte && dataBuffer2 instanceof DataBufferByte) {
        DataBufferByte dataBufferBytes1 = (DataBufferByte) dataBuffer1;
        DataBufferByte dataBufferBytes2 = (DataBufferByte) dataBuffer2;
        for (int bank = 0; bank < dataBufferBytes1.getNumBanks(); bank++) {
            byte[] bytes1 = dataBufferBytes1.getData(bank);
            byte[] bytes2 = dataBufferBytes2.getData(bank);
            if (!Arrays.equals(bytes1, bytes2)) {
                return false;
            }
        }
    } else if (dataBuffer1 instanceof DataBufferInt && dataBuffer2 instanceof DataBufferInt) {
        DataBufferInt dataBufferInt1 = (DataBufferInt) dataBuffer1;
        DataBufferInt dataBufferInt2 = (DataBufferInt) dataBuffer2;
        for (int bank = 0; bank < dataBufferInt1.getNumBanks(); bank++) {
            int[] ints1 = dataBufferInt1.getData(bank);
            int[] ints2 = dataBufferInt2.getData(bank);
            if (!Arrays.equals(ints1, ints2)) {
                return false;
            }
        }
    } else {
        return false;
    }
    return true;
}
 
Example 2
Source File: BytePackedRaster.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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);
}
 
Example 3
Source File: BytePackedRaster.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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);
}
 
Example 4
Source File: BytePackedRaster.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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);
}
 
Example 5
Source File: BytePackedRaster.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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);
}
 
Example 6
Source File: BytePackedRaster.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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);
}
 
Example 7
Source File: BytePackedRaster.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * 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);
}
 
Example 8
Source File: BytePackedRaster.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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);
}
 
Example 9
Source File: BytePackedRaster.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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);
}
 
Example 10
Source File: BytePackedRaster.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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);
}
 
Example 11
Source File: BytePackedRaster.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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);
}
 
Example 12
Source File: BytePackedRaster.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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);
}
 
Example 13
Source File: BytePackedRaster.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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);
}
 
Example 14
Source File: BytePackedRaster.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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);
}
 
Example 15
Source File: BytePackedRaster.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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);
}