PageDrawer.java 文件源码

java
阅读 29 收藏 0 点赞 0 评论 0

项目:sambox 作者:
private BufferedImage create2ByteGrayAlphaImage(int width, int height)
{
    /**
     * gray + alpha
     */
    int[] bandOffsets = new int[] { 1, 0 };
    int bands = bandOffsets.length;

    /**
     * Color Model usesd for raw GRAY + ALPHA
     */
    final ColorModel CM_GRAY_ALPHA = new ComponentColorModel(
            ColorSpace.getInstance(ColorSpace.CS_GRAY), true, false,
            Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE);

    // Init data buffer of type byte
    DataBuffer buffer = new DataBufferByte(width * height * bands);

    // Wrap the data buffer in a raster
    WritableRaster raster = Raster.createInterleavedRaster(buffer, width, height,
            width * bands, bands, bandOffsets, new Point(0, 0));

    // Create a custom BufferedImage with the raster and a suitable color model
    return new BufferedImage(CM_GRAY_ALPHA, raster, false, null);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号