当前位置: 首页>>代码示例>>Java>>正文


Java ByteBandedRaster类代码示例

本文整理汇总了Java中sun.awt.image.ByteBandedRaster的典型用法代码示例。如果您正苦于以下问题:Java ByteBandedRaster类的具体用法?Java ByteBandedRaster怎么用?Java ByteBandedRaster使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ByteBandedRaster类属于sun.awt.image包,在下文中一共展示了ByteBandedRaster类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createBandedRaster

import sun.awt.image.ByteBandedRaster; //导入依赖的package包/类
/**
 * Creates a Raster based on a BandedSampleModel with the
 * specified DataBuffer, width, height, scanline stride, bank
 * indices, and band offsets.  The number of bands is inferred
 * from bankIndices.length and bandOffsets.length, which must be
 * the same.  The upper left corner of the Raster is given by the
 * location argument.  If location is null, (0, 0) will be used.
 * @param dataBuffer the <code>DataBuffer</code> that contains the
 *        image data
 * @param w         the width in pixels of the image data
 * @param h         the height in pixels of the image data
 * @param scanlineStride the line stride of the image data
 * @param bankIndices the bank indices for each band
 * @param bandOffsets the offsets of all bands
 * @param location  the upper-left corner of the <code>Raster</code>
 * @return a WritableRaster object with the specified
 *         <code>DataBuffer</code>, width, height, scanline stride,
 *         bank indices and band offsets.
 * @throws RasterFormatException if <code>w</code> or <code>h</code>
 *         is less than or equal to zero, or computing either
 *         <code>location.x + w</code> or
 *         <code>location.y + h</code> results in integer
 *         overflow
 * @throws IllegalArgumentException if <code>dataType</code> is not
 *         one of the supported data types, which are
 *         <code>DataBuffer.TYPE_BYTE</code>,
 *         <code>DataBuffer.TYPE_USHORT</code>
 *         or <code>DataBuffer.TYPE_INT</code>
 * @throws NullPointerException if <code>dataBuffer</code> is null
 */
public static WritableRaster createBandedRaster(DataBuffer dataBuffer,
                                                int w, int h,
                                                int scanlineStride,
                                                int bankIndices[],
                                                int bandOffsets[],
                                                Point location) {
    if (dataBuffer == null) {
        throw new NullPointerException("DataBuffer cannot be null");
    }
    if (location == null) {
       location = new Point(0,0);
    }
    int dataType = dataBuffer.getDataType();

    int bands = bankIndices.length;
    if (bandOffsets.length != bands) {
        throw new IllegalArgumentException(
                               "bankIndices.length != bandOffsets.length");
    }

    BandedSampleModel bsm =
        new BandedSampleModel(dataType, w, h,
                              scanlineStride,
                              bankIndices, bandOffsets);

    switch(dataType) {
    case DataBuffer.TYPE_BYTE:
        return new ByteBandedRaster(bsm, dataBuffer, location);

    case DataBuffer.TYPE_USHORT:
        return new ShortBandedRaster(bsm, dataBuffer, location);

    case DataBuffer.TYPE_INT:
        return new SunWritableRaster(bsm, dataBuffer, location);

    default:
        throw new IllegalArgumentException("Unsupported data type " +
                                            dataType);
    }
}
 
开发者ID:Java8-CNAPI-Team,项目名称:Java8CN,代码行数:71,代码来源:Raster.java

示例2: createBandedRaster

import sun.awt.image.ByteBandedRaster; //导入依赖的package包/类
/**
 * Creates a Raster based on a BandedSampleModel with the
 * specified DataBuffer, width, height, scanline stride, bank
 * indices, and band offsets.  The number of bands is inferred
 * from bankIndices.length and bandOffsets.length, which must be
 * the same.  The upper left corner of the Raster is given by the
 * location argument.  If location is null, (0, 0) will be used.
 * @param dataBuffer the <code>DataBuffer</code> that contains the
 *        image data
 * @param w         the width in pixels of the image data
 * @param h         the height in pixels of the image data
 * @param scanlineStride the line stride of the image data
 * @param bankIndices the bank indices for each band
 * @param bandOffsets the offsets of all bands
 * @param location  the upper-left corner of the <code>Raster</code>
 * @return a WritableRaster object with the specified
 *         <code>DataBuffer</code>, width, height, scanline stride, 
 *         bank indices and band offsets.
 * @throws RasterFormatException if <code>w</code> or <code>h</code>
 *         is less than or equal to zero, or computing either
 *         <code>location.x + w</code> or
 *         <code>location.y + h</code> results in integer
 *         overflow
 * @throws IllegalArgumentException if <code>dataType</code> is not
 *         one of the supported data types, which are
 *         <code>DataBuffer.TYPE_BYTE</code>, 
 *         <code>DataBuffer.TYPE_USHORT</code> 
 *         or <code>DataBuffer.TYPE_INT</code>
 * @throws NullPointerException if <code>dataBuffer</code> is null
 */
public static WritableRaster createBandedRaster(DataBuffer dataBuffer,
                                                int w, int h,
                                                int scanlineStride,
                                                int bankIndices[],
                                                int bandOffsets[],
                                                Point location) {
    if (dataBuffer == null) {
        throw new NullPointerException("DataBuffer cannot be null");
    }
    if (location == null) {
       location = new Point(0,0);
    }
    int dataType = dataBuffer.getDataType();

    int bands = bankIndices.length;
    if (bandOffsets.length != bands) {
        throw new IllegalArgumentException(
                               "bankIndices.length != bandOffsets.length");
    }

    BandedSampleModel bsm =
        new BandedSampleModel(dataType, w, h,
                              scanlineStride,
                              bankIndices, bandOffsets);

    switch(dataType) {
    case DataBuffer.TYPE_BYTE:
        return new ByteBandedRaster(bsm, dataBuffer, location);

    case DataBuffer.TYPE_USHORT:
        return new ShortBandedRaster(bsm, dataBuffer, location);

    case DataBuffer.TYPE_INT:
        return new SunWritableRaster(bsm, dataBuffer, location);

    default:
        throw new IllegalArgumentException("Unsupported data type " +
                                            dataType);
    }
}
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:71,代码来源:Raster.java


注:本文中的sun.awt.image.ByteBandedRaster类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。