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


Java ImageLayout.setTileGridYOffset方法代码示例

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


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

示例1: layoutHelper

import javax.media.jai.ImageLayout; //导入方法依赖的package包/类
/**
 * Creates the <code>ImageLayout</code> for the image. If the
 * layout parameter is null, create a new <code>ImageLayout</code>
 * from the supplied <code>RenderedImage</code>. Also, force the tile
 * grid offset to equal the image origin and the tile width and height
 * to be equal to the image width and height, respectively, thereby
 * forcing the image to have a single tile.
 *
 * @param layout The <code>ImageLayout</code> to be cloned; may be null.
 * @param source The <code>RenderedImage</code> the attributes of which
 * are to be used as fallbacks in creating a new <code>ImageLayout</code>.
 *
 * @return The <code>ImageLayout</code> to be used.
 */
private static ImageLayout layoutHelper(ImageLayout layout,
                                        Vector sources) {
    if(sources.size() < 1) {
        throw new IllegalArgumentException(JaiI18N.getString("Generic5"));
    }

    RenderedImage source = (RenderedImage)sources.get(0);

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

    // Force the image to have one tile. For this to obtain with minimal
    // tile size the tile grid offset must coincide with the image origin.
    il.setTileGridXOffset(il.getMinX(source));
    il.setTileGridYOffset(il.getMinY(source));
    il.setTileWidth(il.getWidth(source));
    il.setTileHeight(il.getHeight(source));

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

示例2: layoutHelper

import javax.media.jai.ImageLayout; //导入方法依赖的package包/类
/**
 * Sets up the image layout information for this Op.
 * The minX, minY, width, and height are calculated based on
 * the source's dimension and padding values. Any of these
 * values specified in the layout parameter is ignored.
 * All other variables are taken from the layout parameter or
 * inherited from the source.
 */
private static ImageLayout layoutHelper(ImageLayout layout,
                                        RenderedImage source,
                                        int leftPad,
                                        int rightPad,
                                        int topPad,
                                        int bottomPad) {
    ImageLayout il = layout == null ?
        new ImageLayout() : (ImageLayout)layout.clone();

    // Set the image bounds according to the padding.
    il.setMinX(source.getMinX() - leftPad);
    il.setMinY(source.getMinY() - topPad);
    il.setWidth(source.getWidth() + leftPad + rightPad);
    il.setHeight(source.getHeight() + topPad + bottomPad);

    // Set tile grid offset to minimize the probability that a
    // tile's bounds does not intersect the source image bounds.
    if(!il.isValid(ImageLayout.TILE_GRID_X_OFFSET_MASK)) {
        il.setTileGridXOffset(il.getMinX(null));
    }

    if (!il.isValid(ImageLayout.TILE_GRID_Y_OFFSET_MASK)) {
        il.setTileGridYOffset(il.getMinY(null));
    }

    // Force inheritance of source image SampleModel and ColorModel.
    il.setSampleModel(source.getSampleModel());
    il.setColorModel(source.getColorModel());

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

示例3: getImageLayout

import javax.media.jai.ImageLayout; //导入方法依赖的package包/类
@Override
public ImageLayout getImageLayout(String name) throws IOException
{
  log.fine("Getting JAI layout for: " + name);

  if (!checkName(name)) {
    throw new IllegalArgumentException("The specified coverage " + name + "is not found");
  }

  // get the pixel size of the base image
  try
  {
    MrsImageDataProvider dp = DataProviderFactory
        .getMrsImageDataProvider(name, DataProviderFactory.AccessMode.READ, providerProperties);
    MrsPyramidMetadata meta = dp.getMetadataReader().read();

    LongRectangle bounds = meta.getPixelBounds(meta.getMaxZoomLevel());

    ImageLayout layout = new ImageLayout();
    layout.setMinX(0);
    layout.setMinY(0);
    layout.setWidth((int)bounds.getWidth());
    layout.setHeight((int)bounds.getHeight());

    // only 1 tile!
    layout.setTileGridXOffset(0);
    layout.setTileGridYOffset(0);

    layout.setTileWidth((int)bounds.getWidth());
    layout.setTileHeight((int)bounds.getHeight());

    MrsImageReader r = dp.getMrsTileReader(meta.getMaxZoomLevel());

    final Iterator<MrGeoRaster> it = r.get();
    try
    {
      Raster raster = it.next().toRaster();

      layout.setColorModel(RasterUtils.createColorModel(raster));
      layout.setSampleModel(raster.getSampleModel());
    }
    finally
    {
      if (!r.canBeCached() && it instanceof Closeable)
      {
        ((Closeable) it).close();
        r.close();
      }
    }

    return layout;
  }
  catch (IOException e)
  {
    e.printStackTrace();
  }

  return null;

}
 
开发者ID:ngageoint,项目名称:mrgeo-geoserver-plugin,代码行数:61,代码来源:MrGeoReader.java

示例4: createImage

import javax.media.jai.ImageLayout; //导入方法依赖的package包/类
@Override
protected RenderedImage createImage(int level) {
    final List<RenderedImage> tileImages = Collections.synchronizedList(new ArrayList<>(numXTiles * numYTiles));
    double factorX = 1.0 / Math.pow(2, level);
    double factorY = 1.0 / Math.pow(2, level);
    for (int x = 0; x < numYTiles; x++) {
        for (int y = 0; y < numXTiles; y++) {
            PlanarImage opImage;
            try {
                opImage = createTileImage(x, y, level);
                if (opImage != null) {
                    opImage = TranslateDescriptor.create(opImage,
                                                         (float) (y * tileWidth * factorX),
                                                         (float) (x * tileHeight * factorY),
                                                         Interpolation.getInstance(Interpolation.INTERP_NEAREST),
                                                         null);
                }
            } catch (IOException ex) {
                opImage = ConstantDescriptor.create((float) tileWidth, (float) tileHeight, new Number[]{0}, null);
            }
            tileImages.add(opImage);
        }
    }
    if (tileImages.isEmpty()) {
        logger.warning("No tile images for mosaic");
        return null;
    }

    //if (imageLayout == null) {
        imageLayout = new ImageLayout();
        imageLayout.setMinX(0);
        imageLayout.setMinY(0);
        imageLayout.setTileWidth(JAI.getDefaultTileSize().width);
        imageLayout.setTileHeight(JAI.getDefaultTileSize().height);
        imageLayout.setTileGridXOffset(0);
        imageLayout.setTileGridYOffset(0);
        //imageLayout.setSampleModel(ImageUtils.createSingleBandedSampleModel(dataType, imageWidth, imageHeight));
        //imageLayout.setColorModel(ImageUtils.create8BitGreyscaleColorModel());
    //}

    RenderedOp mosaicOp = MosaicDescriptor.create(tileImages.toArray(new RenderedImage[tileImages.size()]),
                                                  MosaicDescriptor.MOSAIC_TYPE_OVERLAY,
                                                  null, null, null, null,
                                                  new RenderingHints(JAI.KEY_IMAGE_LAYOUT, imageLayout));
    int fittingRectWidth = scaleValue(imageWidth, level);
    int fittingRectHeight = scaleValue(imageHeight, level);

    Rectangle fitRect = new Rectangle(0, 0, fittingRectWidth, fittingRectHeight);
    final Rectangle destBounds = DefaultMultiLevelSource.getLevelImageBounds(fitRect, Math.pow(2.0, level));

    BorderExtender borderExtender = BorderExtender.createInstance(BorderExtender.BORDER_COPY);

    if (mosaicOp.getWidth() < destBounds.width || mosaicOp.getHeight() < destBounds.height) {
        int rightPad = destBounds.width - mosaicOp.getWidth();
        int bottomPad = destBounds.height - mosaicOp.getHeight();
        mosaicOp = BorderDescriptor.create(mosaicOp, 0, rightPad, 0, bottomPad, borderExtender, null);
    }

    return mosaicOp;
}
 
开发者ID:senbox-org,项目名称:s2tbx,代码行数:61,代码来源:MosaicMultiLevelSource.java

示例5: createImage

import javax.media.jai.ImageLayout; //导入方法依赖的package包/类
@Override
protected RenderedImage createImage(int level) {
    ArrayList<RenderedImage> tileImages = new ArrayList<>();

    List<String> tiles = sceneDescription.getTileIds().stream().filter(x -> x.contains(tileBandInfo.detectorId)).collect(Collectors.toList());


    TileLayout thisBandTileLayout = this.tileBandInfo.getImageLayout();
    TileLayout productTileLayout = getConfig().getTileLayout(getProductResolution());
    float layoutRatioX = (float) productTileLayout.width / thisBandTileLayout.width;
    float layoutRatioY = (float) productTileLayout.height / thisBandTileLayout.height;


    for (String tileId : tiles) {
        int tileIndex = sceneDescription.getTileIndex(tileId);
        Rectangle tileRectangle = sceneDescription.getTileRectangle(tileIndex);

        PlanarImage opImage = createL1bTileImage(tileId, level);
        {

            double factorX = 1.0 / (Math.pow(2, level) * layoutRatioX);
            double factorY = 1.0 / (Math.pow(2, level) * layoutRatioY);

            opImage = TranslateDescriptor.create(opImage,
                                                 (float) Math.floor((tileRectangle.x * factorX)),
                                                 (float) Math.floor((tileRectangle.y * factorY)),
                                                 Interpolation.getInstance(Interpolation.INTERP_NEAREST), null);

            logger.log(Level.parse(S2Config.LOG_SCENE), String.format("Translate descriptor: %s", ToStringBuilder.reflectionToString(opImage)));
        }

        logger.log(Level.parse(S2Config.LOG_SCENE), String.format("opImage added for level %d at (%d,%d) with size (%d,%d)%n", level, opImage.getMinX(), opImage.getMinY(), opImage.getWidth(), opImage.getHeight()));
        tileImages.add(opImage);
    }

    if (tileImages.isEmpty()) {
        logger.warning("No tile images for mosaic");
        return null;
    }

    ImageLayout imageLayout = new ImageLayout();
    imageLayout.setMinX(0);
    imageLayout.setMinY(0);
    imageLayout.setTileWidth(S2Config.DEFAULT_JAI_TILE_SIZE);
    imageLayout.setTileHeight(S2Config.DEFAULT_JAI_TILE_SIZE);
    imageLayout.setTileGridXOffset(0);
    imageLayout.setTileGridYOffset(0);

    RenderedOp mosaicOp = MosaicDescriptor.create(tileImages.toArray(new RenderedImage[tileImages.size()]),
                                                  MosaicDescriptor.MOSAIC_TYPE_OVERLAY,
                                                  null, null, new double[][]{{1.0}}, new double[]{S2Config.FILL_CODE_MOSAIC_BG},
                                                  new RenderingHints(JAI.KEY_IMAGE_LAYOUT, imageLayout));


    int fitRectWidht = (int) (sceneDescription.getSceneEnvelope().getWidth() /
            (layoutRatioX * getProductResolution().resolution));
    int fitRectHeight = (int) (sceneDescription.getSceneEnvelope().getHeight() /
            (layoutRatioY * getProductResolution().resolution));

    Rectangle fitRect = new Rectangle(0, 0, fitRectWidht, fitRectHeight);
    final Rectangle destBounds = DefaultMultiLevelSource.getLevelImageBounds(fitRect, Math.pow(2.0, level));

    BorderExtender borderExtender = BorderExtender.createInstance(BorderExtender.BORDER_COPY);

    if (mosaicOp.getWidth() < destBounds.width || mosaicOp.getHeight() < destBounds.height) {
        int rightPad = destBounds.width - mosaicOp.getWidth();
        int bottomPad = destBounds.height - mosaicOp.getHeight();
        SystemUtils.LOG.log(Level.parse(S2Config.LOG_SCENE), String.format("Border: (%d, %d), (%d, %d)", mosaicOp.getWidth(), destBounds.width, mosaicOp.getHeight(), destBounds.height));

        mosaicOp = BorderDescriptor.create(mosaicOp, 0, rightPad, 0, bottomPad, borderExtender, null);
    }

    logger.log(Level.parse(S2Config.LOG_SCENE), String.format("mosaicOp created for level %d at (%d,%d) with size (%d, %d)%n", level, mosaicOp.getMinX(), mosaicOp.getMinY(), mosaicOp.getWidth(), mosaicOp.getHeight()));

    return mosaicOp;
}
 
开发者ID:senbox-org,项目名称:s2tbx,代码行数:77,代码来源:Sentinel2L1BProductReader.java


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