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


Java PlanarImage.createColorModel方法代码示例

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


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

示例1: setColorModel

import javax.media.jai.PlanarImage; //导入方法依赖的package包/类
/**
 * Attempts to retrieve or create a <code>ColorModel</code> for the target
 * image.
 *
 * @throws UnsupportedOperationException if a compatible
 *                                       <code>ColorModel</code> is not found
 */
private void setColorModel() {
    assert (targetImage != null);

    colorModel = targetImage.getColorModel();

    if (colorModel == null) {
        SampleModel sm = targetImage.getSampleModel();
        colorModel = PlanarImage.createColorModel(sm);

        if (colorModel == null) {
            // try simple default
            if (ColorModel.getRGBdefault().isCompatibleSampleModel(sm)) {
                colorModel = ColorModel.getRGBdefault();

            } else {
                // admit defeat
                throw new UnsupportedOperationException(
                        "Failed to get or construct a ColorModel for the image");
            }
        }
    }
}
 
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:30,代码来源:DiskMemImageGraphicsOrbit.java

示例2: jiffleProcessExecution

import javax.media.jai.PlanarImage; //导入方法依赖的package包/类
/**
 * Private method used for executing the script operation on an input image with the selected GridGeometry2D.
 * 
 * @param input RenderedImage to process
 * @param jb jiffleBuilder object with the script to execute
 * @param destGridGeometry GridGeometry object associated to the output image
 * @return img output image generated from the script
 * @throws JiffleException
 */
private RenderedImage jiffleProcessExecution(RenderedImage input, JiffleBuilder jb,
        GridGeometry2D destGridGeometry) throws JiffleException {

    // Setting of the source
    jb.source("image", input, null, false);

    // Now we specify the tile dimensions of the final image
    int tileWidth = input.getTileWidth();
    int tileHeight = input.getTileHeight();
    // Creation of a SampleModel associated with the final image
    SampleModel sm = RasterFactory.createPixelInterleavedSampleModel(DataBuffer.TYPE_DOUBLE,
            tileWidth, tileHeight, 1);
    // Selection of the GridEnvelope associated to the input coverage
    final GridEnvelope2D gr2d = destGridGeometry.getGridRange2D();
    // Final image creation
    final WritableRenderedImage img = new TiledImage(gr2d.x, gr2d.y, gr2d.width, gr2d.height,
            0, 0, sm, PlanarImage.createColorModel(sm));
    // Setting of the final image
    jb.dest("dest", img);

    // Finally we run the script and retrieve the resulting image.
    jb.run();

    return img;
}
 
开发者ID:geosolutions-it,项目名称:soil_sealing,代码行数:35,代码来源:JiffleScriptListProcess.java

示例3: colorModelHelper

import javax.media.jai.PlanarImage; //导入方法依赖的package包/类
private static ColorModel colorModelHelper(Number[] bandValues) {
    SampleModel sampleModel = makeSampleModel(1, 1, bandValues);
    return PlanarImage.createColorModel(sampleModel);
}
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:5,代码来源:ConstantOpImage.java

示例4: getCompatibleColorModel

import javax.media.jai.PlanarImage; //导入方法依赖的package包/类
/**
     * Derive a compatible <code>ColorModel</code> for the supplied
     * <code>SampleModel</code> using the method specified via the
     * <code>OpImage</code> configuration <code>Map</code>.
     *
     * @return a compatible <code>ColorModel</code> or <code>null</code>.
     */
    public static ColorModel getCompatibleColorModel(SampleModel sm,
                                                     Map config) {
        ColorModel cm = null;

        if(config == null ||
           !Boolean.FALSE.equals(
               config.get(JAI.KEY_DEFAULT_COLOR_MODEL_ENABLED))) {

            // Set the default ColorModel

            if(config != null &&
               config.containsKey(JAI.KEY_DEFAULT_COLOR_MODEL_METHOD)) {
                // Attempt to retrieve the default CM Method.
                Method cmMethod =
                    (Method)config.get(JAI.KEY_DEFAULT_COLOR_MODEL_METHOD);

                // Check method compatibility.
                Class[] paramTypes = cmMethod.getParameterTypes();
                if((cmMethod.getModifiers() & Modifier.STATIC) !=
                   Modifier.STATIC) {
                    // Method must be static.
                    throw new RuntimeException(JaiI18N.getString("ImageUtil1"));
                } else if(cmMethod.getReturnType() != ColorModel.class) {
                    // Method must return a ColorModel.
                    throw new RuntimeException(JaiI18N.getString("ImageUtil2"));
                } else if(paramTypes.length != 1 ||
                          !paramTypes[0].equals(SampleModel.class)) {
                    // Unique Method parameter must be a SampleModel.
                    throw new RuntimeException(JaiI18N.getString("ImageUtil3"));
                }

                // Set the default ColorModel.
                try {
                    // Attempt to use the supplied Method.
                    Object[] args = new Object[] {sm};
                    cm = (ColorModel)cmMethod.invoke(null, args);
                } catch(Exception e) {
                    String message =
                        JaiI18N.getString("ImageUtil4") + cmMethod.getName();
                    sendExceptionToListener(message ,
                                            new ImagingException(message, e));
/*
                    // XXX Is this a reasonable Exception to throw?
                    throw new RuntimeException(cmMethod.getName()+" "+
                                               e.getMessage());
*/
                }
            } else { // No default method hint set.
                // Use PlanarImage method.
                cm = PlanarImage.createColorModel(sm);
            }
        }

        return cm;
    }
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:63,代码来源:ImageUtil.java


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