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


Java DataBufferInt.getBankData方法代码示例

本文整理汇总了Java中java.awt.image.DataBufferInt.getBankData方法的典型用法代码示例。如果您正苦于以下问题:Java DataBufferInt.getBankData方法的具体用法?Java DataBufferInt.getBankData怎么用?Java DataBufferInt.getBankData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.image.DataBufferInt的用法示例。


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

示例1: compose

import java.awt.image.DataBufferInt; //导入方法依赖的package包/类
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;
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:30,代码来源:CustomCompositeTest.java

示例2: read8BitBitmap

import java.awt.image.DataBufferInt; //导入方法依赖的package包/类
private static BufferedImage read8BitBitmap(int nColoursUsed, int nBitCount, int nSizeImage, int nWidth, int nHeight, InputStream input) throws IOException {
    int nNumColors = (nColoursUsed > 0) ? nColoursUsed : (1 & 0xff) << nBitCount;

    if (nSizeImage == 0) {
        nSizeImage = ((((nWidth * nBitCount) + 31) & ~31) >> 3);
        nSizeImage *= nHeight;
    }

    int npalette[] = new int[nNumColors];
    byte bpalette[] = new byte[nNumColors * 4];
    readBuffer(input, bpalette);
    int nindex8 = 0;

    for (int n = 0; n < nNumColors; n++) {
        npalette[n] = (255 & 0xff) << 24 |
                (bpalette[nindex8 + 2] & 0xff) << 16 |
                (bpalette[nindex8 + 1] & 0xff) << 8 |
                (bpalette[nindex8 + 0] & 0xff);

        nindex8 += 4;
    }

    int npad8 = (nSizeImage / nHeight) - nWidth;
    BufferedImage bufferedImage = new BufferedImage(nWidth, nHeight, BufferedImage.TYPE_INT_ARGB);
    DataBufferInt dataBufferByte = ((DataBufferInt) bufferedImage.getRaster().getDataBuffer());
    int[][] bankData = dataBufferByte.getBankData();
    byte bdata[] = new byte[(nWidth + npad8) * nHeight];

    readBuffer(input, bdata);
    nindex8 = 0;

    for (int j8 = nHeight - 1; j8 >= 0; j8--) {
        for (int i8 = 0; i8 < nWidth; i8++) {
            bankData[0][j8 * nWidth + i8] = npalette[((int) bdata[nindex8] & 0xff)];
            nindex8++;
        }
        nindex8 += npad8;
    }

    return bufferedImage;
}
 
开发者ID:claudiu-ancau-rm,项目名称:GUI,代码行数:42,代码来源:BitmapLoader.java


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