當前位置: 首頁>>代碼示例>>Java>>正文


Java DataBufferInt.getNumBanks方法代碼示例

本文整理匯總了Java中java.awt.image.DataBufferInt.getNumBanks方法的典型用法代碼示例。如果您正苦於以下問題:Java DataBufferInt.getNumBanks方法的具體用法?Java DataBufferInt.getNumBanks怎麽用?Java DataBufferInt.getNumBanks使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.image.DataBufferInt的用法示例。


在下文中一共展示了DataBufferInt.getNumBanks方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: IntegerComponentRaster

import java.awt.image.DataBufferInt; //導入方法依賴的package包/類
/**
 * 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();
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:69,代碼來源:IntegerComponentRaster.java

示例2: IntegerComponentRaster

import java.awt.image.DataBufferInt; //導入方法依賴的package包/類
/**
 * 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();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:66,代碼來源:IntegerComponentRaster.java


注:本文中的java.awt.image.DataBufferInt.getNumBanks方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。