Exemplo n.º 1
0
  @SuppressWarnings("deprecation")
  @Override
  public RenderedImage create(ParameterBlock paramBlock, RenderingHints renderHints) {
    ImageLayout layout = RIFUtil.getImageLayoutHint(renderHints);

    RenderedImage source = paramBlock.getRenderedSource(0);
    double scaleX = paramBlock.getDoubleParameter(0);
    double scaleY = paramBlock.getDoubleParameter(1);

    // Check and see if we are scaling by 1.0 in both x and y and no
    // translations. If so return the source directly.
    if (scaleX == 1.0 && scaleY == 1.0) {
      return source;
    }

    return new LanczosOpImage(source, layout, renderHints, scaleX, scaleY);
  }
Exemplo n.º 2
0
  /**
   * Creates a new instance of <code>MlibWarpOpImage</code> in the rendered image mode.
   *
   * @param args The source images.
   * @param hints May contain rendering hints and destination image layout.
   */
  public RenderedImage create(ParameterBlock args, RenderingHints hints) {
    /* Get ImageLayout and TileCache from RenderingHints. */
    ImageLayout layout = RIFUtil.getImageLayoutHint(hints);

    RenderedImage source = args.getRenderedSource(0);

    if (!MediaLibAccessor.isMediaLibCompatible(args, layout)
        || !MediaLibAccessor.hasSameNumBands(args, layout)
        ||
        // Medialib cannot deal with source image having tiles with any
        // dimension greater than or equal to 32768
        source.getTileWidth() >= 32768
        || source.getTileHeight() >= 32768) {
      return null;
    }

    /* Get BorderExtender from hints if any. */
    BorderExtender extender = RIFUtil.getBorderExtenderHint(hints);

    Warp warp = (Warp) args.getObjectParameter(0);
    Interpolation interp = (Interpolation) args.getObjectParameter(1);
    double[] backgroundValues = (double[]) args.getObjectParameter(2);

    int filter = -1;
    if (interp instanceof InterpolationNearest) {
      filter = Constants.MLIB_NEAREST;
    } else if (interp instanceof InterpolationBilinear) {
      filter = Constants.MLIB_BILINEAR;
    } else if (interp instanceof InterpolationBicubic) {
      filter = Constants.MLIB_BICUBIC;
    } else if (interp instanceof InterpolationBicubic2) {
      filter = Constants.MLIB_BICUBIC2;
    } else if (interp instanceof InterpolationTable) {;
      // filter =  Constants.MLIB_TABLE; not defined yet;
    } else {
      /* Other kinds of interpolation cannot be handled via mlib. */
      return null;
    }

    if (warp instanceof WarpGrid) {
      if (interp instanceof InterpolationTable) {
        return new MlibWarpGridTableOpImage(
            source, extender, hints, layout, (WarpGrid) warp, interp, backgroundValues);
      } else {
        return new MlibWarpGridOpImage(
            source, extender, hints, layout, (WarpGrid) warp, interp, filter, backgroundValues);
      }

    } else if (warp instanceof WarpPolynomial) {
      if (interp instanceof InterpolationTable) {
        return new MlibWarpPolynomialTableOpImage(
            source, extender, hints, layout, (WarpPolynomial) warp, interp, backgroundValues);
      } else {
        return new MlibWarpPolynomialOpImage(
            source,
            extender,
            hints,
            layout,
            (WarpPolynomial) warp,
            interp,
            filter,
            backgroundValues);
      }
    } else {
      return null;
    }
  }