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


Java ColorModel.getTransferType方法代码示例

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


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

示例1: createXorPixelWriter

import java.awt.image.ColorModel; //导入方法依赖的package包/类
static PixelWriter createXorPixelWriter(SunGraphics2D sg2d,
                                        SurfaceData sData)
{
    ColorModel dstCM = sData.getColorModel();

    Object srcPixel = dstCM.getDataElements(sg2d.eargb, null);

    XORComposite comp = (XORComposite)sg2d.getComposite();
    int xorrgb = comp.getXorColor().getRGB();
    Object xorPixel = dstCM.getDataElements(xorrgb, null);

    switch (dstCM.getTransferType()) {
    case DataBuffer.TYPE_BYTE:
        return new XorPixelWriter.ByteData(srcPixel, xorPixel);
    case DataBuffer.TYPE_SHORT:
    case DataBuffer.TYPE_USHORT:
        return new XorPixelWriter.ShortData(srcPixel, xorPixel);
    case DataBuffer.TYPE_INT:
        return new XorPixelWriter.IntData(srcPixel, xorPixel);
    case DataBuffer.TYPE_FLOAT:
        return new XorPixelWriter.FloatData(srcPixel, xorPixel);
    case DataBuffer.TYPE_DOUBLE:
        return new XorPixelWriter.DoubleData(srcPixel, xorPixel);
    default:
        throw new InternalError("Unsupported XOR pixel type");
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:28,代码来源:GeneralRenderer.java

示例2: rgbToPixel

import java.awt.image.ColorModel; //导入方法依赖的package包/类
public int rgbToPixel(int rgb, ColorModel cm) {
    Object obj = cm.getDataElements(rgb, null);
    switch (cm.getTransferType()) {
    case DataBuffer.TYPE_BYTE:
        byte[] bytearr = (byte[]) obj;
        int pix = 0;

        switch(bytearr.length) {
        default: // bytearr.length >= 4
            pix = bytearr[3] << 24;
            // FALLSTHROUGH
        case 3:
            pix |= (bytearr[2] & 0xff) << 16;
            // FALLSTHROUGH
        case 2:
            pix |= (bytearr[1] & 0xff) << 8;
            // FALLSTHROUGH
        case 1:
            pix |= (bytearr[0] & 0xff);
        }

        return pix;
    case DataBuffer.TYPE_SHORT:
    case DataBuffer.TYPE_USHORT:
        short[] shortarr = (short[]) obj;

        return (((shortarr.length > 1) ? shortarr[1] << 16 : 0) |
                shortarr[0] & 0xffff);
    case DataBuffer.TYPE_INT:
        return ((int[]) obj)[0];
    default:
        return rgb;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:35,代码来源:PixelConverter.java

示例3: rgbToPixel

import java.awt.image.ColorModel; //导入方法依赖的package包/类
@SuppressWarnings("fallthrough")
public int rgbToPixel(int rgb, ColorModel cm) {
    Object obj = cm.getDataElements(rgb, null);
    switch (cm.getTransferType()) {
    case DataBuffer.TYPE_BYTE:
        byte[] bytearr = (byte[]) obj;
        int pix = 0;

        switch(bytearr.length) {
        default: // bytearr.length >= 4
            pix = bytearr[3] << 24;
            // FALLSTHROUGH
        case 3:
            pix |= (bytearr[2] & 0xff) << 16;
            // FALLSTHROUGH
        case 2:
            pix |= (bytearr[1] & 0xff) << 8;
            // FALLSTHROUGH
        case 1:
            pix |= (bytearr[0] & 0xff);
        }

        return pix;
    case DataBuffer.TYPE_SHORT:
    case DataBuffer.TYPE_USHORT:
        short[] shortarr = (short[]) obj;

        return (((shortarr.length > 1) ? shortarr[1] << 16 : 0) |
                shortarr[0] & 0xffff);
    case DataBuffer.TYPE_INT:
        return ((int[]) obj)[0];
    default:
        return rgb;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:36,代码来源:PixelConverter.java


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