Exemplo n.º 1
0
  /** The main method. */
  public static void main(String[] args)
      throws IOException, InterruptedException, Correlate.CorrelateException {
    // First parse the command line and test for various
    //  settings.
    if (!commandLine(args)) System.exit(-1);

    // Set the tile cache up on JAI
    TileCache tc = JAI.createTileCache(tileCacheSize);
    JAI jai = JAI.getDefaultInstance();
    jai.setTileCache(tc);

    /*
     * Create an input stream from the specified file name
     * to be used with the file decoding operator.
     */
    FileSeekableStream stream = null;
    try {
      stream = new FileSeekableStream(inputImageFilename);
    } catch (IOException e) {
      e.printStackTrace();
      System.exit(0);
    }

    /* Create an operator to decode the image file. */
    RenderedImage inputImage = JAI.create("stream", stream);

    ParameterBlock pb = new ParameterBlock();
    pb.addSource(inputImage);
    pb.add(new Float(10.0));
    pb.add(new Float(10.0));
    // Perform the color conversion.
    RenderedImage processedImage = JAI.create("Scale", pb, null);

    JAI.create("filestore", processedImage, outputImageFilename, encoder, null);
  }
Exemplo n.º 2
0
  public RenderedImage create(ParameterBlock paramBlock, RenderingHints renderHints) {
    RenderedImage source = paramBlock.getRenderedSource(0);

    ImageLayout layout =
        renderHints == null ? null : (ImageLayout) renderHints.get(JAI.KEY_IMAGE_LAYOUT);

    String algorism = (String) paramBlock.getObjectParameter(0);
    int level = paramBlock.getIntParameter(1);
    Vector[] coefs = (Vector[]) paramBlock.getObjectParameter(2);

    return new QuantizationOpImage(source, layout, renderHints, algorism, level, coefs);
  }