• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java ColorScaler类的典型用法和代码示例

java 1次浏览

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

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

示例1: filter

点赞 2

import org.apache.harmony.awt.gl.color.ColorScaler; //导入依赖的package包/类
public final WritableRaster filter(Raster src, WritableRaster dst) {
    if (conversionSequence.length < 2) {
        throw new IllegalArgumentException(Messages.getString("awt.25D")); //$NON-NLS-1$
    }

    ICC_Profile srcPf = null, dstPf = null; // unused if isICC is false
    int nSrcColorComps, nDstColorComps;
    Object first = conversionSequence[0];
    Object last = conversionSequence[conversionSequence.length - 1];

    // Get the number of input/output color components
    if (isICC) {
        srcPf = (ICC_Profile)first;
        dstPf = (ICC_Profile)last;
        nSrcColorComps = srcPf.getNumComponents();
        nDstColorComps = dstPf.getNumComponents();
    } else {
        if (first instanceof ICC_Profile) {
            srcPf = (ICC_Profile)first;
            nSrcColorComps = srcPf.getNumComponents();
        } else {
            nSrcColorComps = ((ColorSpace)first).getNumComponents();
        }

        if (last instanceof ICC_Profile) {
            dstPf = (ICC_Profile)last;
            nDstColorComps = dstPf.getNumComponents();
        } else {
            nDstColorComps = ((ColorSpace)last).getNumComponents();
        }
    }

    // Check that source and destination rasters are compatible with
    // transforms and with each other
    if (src.getNumBands() != nSrcColorComps) {
        // awt.25E=Incorrect number of source raster bands. Should be equal
        // to the number of color components of source colorspace.
        throw new IllegalArgumentException(Messages.getString("awt.25E")); //$NON-NLS-1$
    }

    if (dst != null) { // Check destination raster
        if (dst.getNumBands() != nDstColorComps) {
            // awt.25F=Incorrect number of destination raster bands. Should
            // be equal to the number of color components of destination
            // colorspace.
            throw new IllegalArgumentException(Messages.getString("awt.25F")); //$NON-NLS-1$
        }

        if (src.getWidth() != dst.getWidth() || src.getHeight() != dst.getHeight()) {
            throw new IllegalArgumentException(Messages.getString("awt.260")); //$NON-NLS-1$
        }

    } else {
        dst = createCompatibleDestRaster(src);
    }

    if (isICC) {
        // Create transform
        ICC_Transform t = tCreator
                .getTransform(srcPf, dstPf, (ICC_Profile[])conversionSequence);
        cc.translateColor(t, src, dst);
    } else {
        Object[] sequence = tCreator.getSequence(null, null);

        // Get data from the source raster
        ColorScaler scaler = new ColorScaler();
        scaler.loadScalingData(src, null);
        float tmpData[][] = scaler.scaleNormalize(src);

        // Get source and destination color spaces
        ColorSpace srcCS = (srcPf == null) ? (ColorSpace)first : new ICC_ColorSpace(srcPf);
        ColorSpace dstCS = (dstPf == null) ? (ColorSpace)last : new ICC_ColorSpace(dstPf);

        applySequence(sequence, tmpData, srcCS, dstCS);

        scaler.loadScalingData(dst, null);
        scaler.unscaleNormalized(dst, tmpData);
    }

    return dst;
}
 

开发者ID:dritanlatifi,
项目名称:AndroidPrefuse,
代码行数:82,
代码来源:ColorConvertOp.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)