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


Java ImageLayout.getSampleModel方法代码示例

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


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

示例1: sampleModelHelper

import javax.media.jai.ImageLayout; //导入方法依赖的package包/类
private static SampleModel sampleModelHelper(int numBands,
                                             ImageLayout layout) {
    SampleModel sampleModel;
    if (layout!= null && layout.isValid(ImageLayout.SAMPLE_MODEL_MASK)) {
        sampleModel = layout.getSampleModel(null);

        if (sampleModel.getNumBands() != numBands) {
            throw new RuntimeException(JaiI18N.getString("ImageFunctionRIF0"));
        }
    } else { // Create a SampleModel.
        // Use a dummy width and height, OpImage will fix them
        sampleModel = RasterFactory.createBandedSampleModel(
                                                      DataBuffer.TYPE_FLOAT,
                                                      1, 1,
                                                      numBands);
    }

    return sampleModel;
}
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:20,代码来源:ImageFunctionOpImage.java

示例2: WarpSourceCoordinatesOpImage

import javax.media.jai.ImageLayout; //导入方法依赖的package包/类
private WarpSourceCoordinatesOpImage(Warp warp, ImageLayout layout, Map configuration) {
    super(layout, configuration, layout.getSampleModel(null), layout.getMinX(null), layout.getMinY(null),
            layout.getWidth(null), layout.getHeight(null));
    this.warp = warp;
    int compatibleTag = RasterAccessor.findCompatibleTag(null, layout.getSampleModel(null));
    rasterFormatTag = new RasterFormatTag(layout.getSampleModel(null), compatibleTag);
    OperatorContext.setTileCache(this);
}
 
开发者ID:senbox-org,项目名称:s2tbx,代码行数:9,代码来源:WarpSourceCoordinatesOpImage.java

示例3: AWTImageOpImage

import javax.media.jai.ImageLayout; //导入方法依赖的package包/类
/**
   * Constructs an AWTImageOpImage.
   *
   * @param layout  Image layout.
   * @param image   The AWT image.
   */
  public AWTImageOpImage(Map config,
                         ImageLayout layout,
                         Image image) {
      // We don't know the width, height, and sample model yet
      super(layout = layoutHelper(layout, image), config,
            layout.getSampleModel(null),
            layout.getMinX(null), layout.getMinY(null),
            layout.getWidth(null), layout.getHeight(null));

      // Set the format tag if and only if we will use the RasterAccessor.
      if(getTileWidth() != getWidth() || getTileHeight() != getHeight()) {
          rasterFormatTag =
              new RasterFormatTag(getSampleModel(),
                                  RasterAccessor.TAG_BYTE_UNCOPIED);
      }

      // Grab the entire image
      this.pixels = new int[width * height];
      PixelGrabber grabber = new PixelGrabber(image, 0, 0, width, height,
                                              pixels, 0, width);
      try {
          if (!grabber.grabPixels()) {
              if ((grabber.getStatus() & ImageObserver.ABORT) != 0) {
                  throw new RuntimeException(JaiI18N.getString("AWTImageOpImage2"));
} else {
                  throw new RuntimeException(grabber.getStatus() + JaiI18N.getString("AWTImageOpImage3"));
              }
          }
      } catch (InterruptedException e) {
          e.printStackTrace();
          throw new RuntimeException(JaiI18N.getString("AWTImageOpImage4"));
      }
  }
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:40,代码来源:AWTImageOpImage.java

示例4: layoutHelper

import javax.media.jai.ImageLayout; //导入方法依赖的package包/类
/**
    * Force the destination image to be single-banded.
    */
   private static ImageLayout layoutHelper(ImageLayout layout,
                                           RenderedImage source) {
       // Create or clone the layout.
       ImageLayout il = layout == null ?
    new ImageLayout() : (ImageLayout)layout.clone();

       // Force the destination and source origins and dimensions to coincide.
       il.setMinX(source.getMinX());
       il.setMinY(source.getMinY());
       il.setWidth(source.getWidth());
       il.setHeight(source.getHeight());

       // Get the SampleModel.
       SampleModel sm = il.getSampleModel(source);

       // Make sure that this OpImage is single-banded.
       if (sm.getNumBands() != 1) {
           sm =
               RasterFactory.createComponentSampleModel(sm,
                                                        sm.getTransferType(),
                                                        sm.getWidth(),
                                                        sm.getHeight(),
                                                        1);
    il.setSampleModel(sm);
       }

       il.setColorModel(null);

return il;
   }
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:34,代码来源:ColorQuantizerOpImage.java

示例5: layoutHelper

import javax.media.jai.ImageLayout; //导入方法依赖的package包/类
/**
 * Override the dimension specification for the destination such that it
 * has width and height which are equal to non-negative powers of 2.
 */
private static ImageLayout layoutHelper(ImageLayout layout,
                                        RenderedImage source) {
    // Create an ImageLayout or clone the one passed in.
    ImageLayout il = layout == null ?
        new ImageLayout() : (ImageLayout)layout.clone();

    // Force the origin to coincide with that of the source.
    il.setMinX(source.getMinX());
    il.setMinY(source.getMinY());

    // Recalculate the non-unity dimensions to be a positive power of 2.
    // XXX This calculation should not be effected if an implementation
    // of the FCT which supports arbitrary dimensions is used.
    boolean createNewSampleModel = false;
    int w = il.getWidth(source);
    if(w > 1) {
        int newWidth = MathJAI.nextPositivePowerOf2(w);
        if(newWidth != w) {
            il.setWidth(w = newWidth);
            createNewSampleModel = true;
        }
    }
    int h = il.getHeight(source);
    if(h > 1) {
        int newHeight = MathJAI.nextPositivePowerOf2(h);
        if(newHeight != h) {
            il.setHeight(h = newHeight);
            createNewSampleModel = true;
        }
    }

    // Force the image to contain floating point data.
    SampleModel sm = il.getSampleModel(source);
    int dataType = sm.getTransferType();
    if(dataType != DataBuffer.TYPE_FLOAT &&
       dataType != DataBuffer.TYPE_DOUBLE) {
        dataType = DataBuffer.TYPE_FLOAT;
        createNewSampleModel = true;
    }

    // Create a new SampleModel for the destination.
    if(createNewSampleModel) {
        sm = RasterFactory.createComponentSampleModel(sm, dataType, w, h,
                                                      sm.getNumBands());
        il.setSampleModel(sm);

        // Clear the ColorModel mask if needed.
        ColorModel cm = il.getColorModel(null);
        if(cm != null &&
           !JDKWorkarounds.areCompatibleDataModels(sm, cm)) {
            // Clear the mask bit if incompatible.
            il.unsetValid(ImageLayout.COLOR_MODEL_MASK);
        }
    }

    return il;
}
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:62,代码来源:DCTOpImage.java

示例6: layoutHelper

import javax.media.jai.ImageLayout; //导入方法依赖的package包/类
private static ImageLayout layoutHelper(Vector sources,
                                        ImageLayout il) {

    ImageLayout layout = (il == null) ? new ImageLayout() : (ImageLayout)il.clone();

    int numSources = sources.size();

    // dest data type is the maximum of transfertype of source image
    // utilizing the monotonicity of data types.

    // dest number of bands = sum of source bands
    int destNumBands = totalNumBands(sources);

    int destDataType = DataBuffer.TYPE_BYTE;  // initialize
    RenderedImage srci = (RenderedImage)sources.get(0);
    Rectangle destBounds = new Rectangle(srci.getMinX(),  srci.getMinY(),
                                         srci.getWidth(), srci.getHeight());                                             
    for ( int i = 0; i < numSources; i++ ) {
        srci = (RenderedImage)sources.get(i);
        destBounds = destBounds.intersection(new Rectangle(srci.getMinX(), srci.getMinY(),
                                             srci.getWidth(), srci.getHeight()));

        int typei = srci.getSampleModel().getTransferType();

        // NOTE: this depends on JDK ordering
        destDataType = typei > destDataType ? typei : destDataType;
    }

    SampleModel sm = layout.getSampleModel((RenderedImage)sources.get(0));

    if ( sm.getNumBands() < destNumBands ) {
        int[] destOffsets = new int[destNumBands];

        for(int i=0; i < destNumBands; i++) {
            destOffsets[i] = i;
        }

        // determine the proper width and height to use
        int destTileWidth = sm.getWidth();
        int destTileHeight = sm.getHeight();
        if(layout.isValid(ImageLayout.TILE_WIDTH_MASK))
        {
            destTileWidth =
                layout.getTileWidth((RenderedImage)sources.get(0));
        }
        if(layout.isValid(ImageLayout.TILE_HEIGHT_MASK))
        {
            destTileHeight =
                layout.getTileHeight((RenderedImage)sources.get(0));
        }
        
        sm = RasterFactory.createComponentSampleModel(sm,
                                                      destDataType,
                                                      destTileWidth,
                                                      destTileHeight,
                                                      destNumBands);


        layout.setSampleModel(sm);
    }

    ColorModel cm = layout.getColorModel(null);

    if ( cm != null &&
         !JDKWorkarounds.areCompatibleDataModels(sm, cm)) {
        // Clear the mask bit if incompatible.
        layout.unsetValid(ImageLayout.COLOR_MODEL_MASK);
    }

    return layout;
}
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:72,代码来源:BandMergeOpImage.java

示例7: AddOpImage

import javax.media.jai.ImageLayout; //导入方法依赖的package包/类
/**
 * Constructs an <code>AddOpImage</code>.
 *
 * <p>The <code>layout</code> parameter may optionally contains the
 * tile grid layout, sample model, and/or color model. The image
 * dimension is determined by the intersection of the bounding boxes
 * of the two source images.
 *
 * <p>The image layout of the first source image, <code>source1</code>,
 * is used as the fall-back for the image layout of the destination
 * image. Any layout parameters not specified in the <code>layout</code>
 * argument are set to the same value as that of <code>source1</code>.
 *
 * @param source1  The first source image.
 * @param source2  The second source image.
 * @param layout   The destination image layout.
 */
public AddOpImage(RenderedImage source1,
                  RenderedImage source2, 
                  Map config,
    ImageLayout layout) {
    super(source1, source2, layout, config, true);

    if(ImageUtil.isBinary(getSampleModel()) &&
       ImageUtil.isBinary(source1.getSampleModel()) &&
       ImageUtil.isBinary(source2.getSampleModel())) {
        // Binary processing case: RasterAccessor
        areBinarySampleModels = true;
    } else {
        // Get the source band counts.
        int numBands1 = source1.getSampleModel().getNumBands();
        int numBands2 = source2.getSampleModel().getNumBands();

        // Handle the special case of adding a single band image to
        // each band of a multi-band image.
        int numBandsDst;
        if(layout != null && layout.isValid(ImageLayout.SAMPLE_MODEL_MASK)) {
            SampleModel sm = layout.getSampleModel(null);
            numBandsDst = sm.getNumBands();

            // One of the sources must be single-banded and the other must
            // have at most the number of bands in the SampleModel hint.
            if(numBandsDst > 1 &&
               ((numBands1 == 1 && numBands2 > 1) ||
                (numBands2 == 1 && numBands1 > 1))) {
                // Clamp the destination band count to the number of
                // bands in the multi-band source.
                numBandsDst = Math.min(Math.max(numBands1, numBands2),
                                       numBandsDst);

                // Create a new SampleModel if necessary.
                if(numBandsDst != sampleModel.getNumBands()) {
                    sampleModel =
                        RasterFactory.createComponentSampleModel(
                            sm,
                            sampleModel.getTransferType(),
                            sampleModel.getWidth(),
                            sampleModel.getHeight(),
                            numBandsDst);

                    if(colorModel != null &&
                       !JDKWorkarounds.areCompatibleDataModels(sampleModel,
                                                               colorModel)) {
                        colorModel =
                            ImageUtil.getCompatibleColorModel(sampleModel,
                                                              config);
                    }
                }

                // Set the source band increments.
                s1bd = numBands1 == 1 ? 0 : 1;
                s2bd = numBands2 == 1 ? 0 : 1;
            }
        }
    }

    // Set flag to permit in-place operation.
    permitInPlaceOperation();
}
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:80,代码来源:AddOpImage.java

示例8: SubtractOpImage

import javax.media.jai.ImageLayout; //导入方法依赖的package包/类
/**
 * Constructs an <code>SubtractOpImage</code>.
 *
 * <p>The <code>layout</code> parameter may optionally contains the
 * tile grid layout, sample model, and/or color model. The image
 * dimension is determined by the intersection of the bounding boxes
 * of the two source images.
 *
 * <p>The image layout of the first source image, <code>source1</code>,
 * is used as the fall-back for the image layout of the destination
 * image. Any layout parameters not specified in the <code>layout</code>
 * argument are set to the same value as that of <code>source1</code>.
 *
 * @param source1  The first source image.
 * @param source2  The second source image.
 * @param layout   The destination image layout.
 */
public SubtractOpImage(RenderedImage source1,
                       RenderedImage source2, 
                       Map config,
         ImageLayout layout) {
    super(source1, source2, layout, config, true);
    // Get the source band counts.
    int numBands1 = source1.getSampleModel().getNumBands();
    int numBands2 = source2.getSampleModel().getNumBands();

    // Handle the special case of subtracting from each band of an N-band
    // image a single-band image.
    int numBandsDst;
    if(layout != null && layout.isValid(ImageLayout.SAMPLE_MODEL_MASK)) {
        SampleModel sm = layout.getSampleModel(null);
        numBandsDst = sm.getNumBands();

        // The second source must be single-banded and the first must
        // be multi-banded.
        if(numBandsDst > 1 &&
           ((numBands1 > 1 && numBands2 == 1) ||
            (numBands1 == 1 && numBands2 > 1))) {
            // Clamp the destination band count to the number of
            // bands in the multi-band source.
            numBandsDst = Math.min(Math.max(numBands1, numBands2),
                                   numBandsDst);

            // Create a new SampleModel if necessary.
            if(numBandsDst != sampleModel.getNumBands()) {
                sampleModel =
                    RasterFactory.createComponentSampleModel(
                        sm,
                        sampleModel.getTransferType(),
                        sampleModel.getWidth(),
                        sampleModel.getHeight(),
                        numBandsDst);

                if(colorModel != null &&
                   !JDKWorkarounds.areCompatibleDataModels(sampleModel,
                                                           colorModel)) {
                    colorModel =
                        ImageUtil.getCompatibleColorModel(sampleModel,
                                                          config);
                }
            }

            // Set the source band increments.
            s1bd = numBands1 == 1 ? 0 : 1;
            s2bd = numBands2 == 1 ? 0 : 1;
        }
    }

    // Set flag to permit in-place operation.
    permitInPlaceOperation();
}
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:72,代码来源:SubtractOpImage.java

示例9: layoutHelper

import javax.media.jai.ImageLayout; //导入方法依赖的package包/类
/**
 * Force the destination image to have a signed data type.
 */
private static ImageLayout layoutHelper(ImageLayout layout,
                                        RenderedImage source) {
    // Create or clone the layout.
    ImageLayout il = layout == null ?
        new ImageLayout() : (ImageLayout)layout.clone();

    // Get the reference SampleModel.
    SampleModel sm = il.getSampleModel(source);

    // Get the data type.
    int dataType = sm.getTransferType();

    // Determine whether the destination requires a different data type
    // and set it if so.
    boolean createNewSampleModel = false;
    if(dataType == DataBuffer.TYPE_BYTE) {
        dataType = DataBuffer.TYPE_SHORT;
        createNewSampleModel = true;
    } else if(dataType == DataBuffer.TYPE_USHORT) {
        dataType = DataBuffer.TYPE_INT;
        createNewSampleModel = true;
    }

    // Create a new SampleModel for the destination if necessary.
    if(createNewSampleModel) {
        sm = RasterFactory.createComponentSampleModel(sm, dataType,
                                                      sm.getWidth(),
                                                      sm.getHeight(),
                                                      sm.getNumBands());

        il.setSampleModel(sm);

        // Check ColorModel.
        ColorModel cm = il.getColorModel(null);
        if(cm != null &&
           !JDKWorkarounds.areCompatibleDataModels(sm, cm)) {
            // Clear the mask bit if incompatible.
            il.unsetValid(ImageLayout.COLOR_MODEL_MASK);
        }
    }

    return il;
}
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:47,代码来源:ConjugateOpImage.java


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