Example usage for java.awt.image BandedSampleModel BandedSampleModel

List of usage examples for java.awt.image BandedSampleModel BandedSampleModel

Introduction

In this page you can find the example usage for java.awt.image BandedSampleModel BandedSampleModel.

Prototype

public BandedSampleModel(int dataType, int w, int h, int scanlineStride, int[] bankIndices, int[] bandOffsets) 

Source Link

Document

Constructs a BandedSampleModel with the specified parameters.

Usage

From source file:it.geosolutions.imageio.plugins.nitronitf.ImageIOUtils.java

/**
 * Returns a generic banded WritableRaster
 * //from   ww w .  j a v a 2s .c o m
 * @param numElems
 * @param numLines
 * @param bandOffsets
 * @param dataType
 * @return
 */
public static WritableRaster makeGenericBandedWritableRaster(int numElems, int numLines, int numBands,
        int dataType) {
    int[] bandOffsets = new int[numBands];
    for (int i = 0; i < numBands; ++i)
        bandOffsets[i] = i;

    DataBuffer d = null;
    if (dataType == DataBuffer.TYPE_BYTE)
        d = new DataBufferByte(numElems * numLines * numBands);
    else if (dataType == DataBuffer.TYPE_FLOAT)
        d = new DataBufferFloat(numElems * numLines * numBands);
    else
        throw new IllegalArgumentException("Invalid datatype: " + dataType);

    BandedSampleModel bsm = new BandedSampleModel(dataType, numElems, numLines, bandOffsets.length, bandOffsets,
            bandOffsets);

    SunWritableRaster ras = new SunWritableRaster(bsm, d, new Point(0, 0));
    return ras;
}