コード例 #1
0
ファイル: ConvertImage.java プロジェクト: jimfcarroll/nrimage
  /** 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);
  }
コード例 #2
0
ファイル: JCanvas.java プロジェクト: xaleth09/Connect4-AI
 private void chkFPS() {
   if (fpsCount == 0) {
     fpsTime = System.currentTimeMillis() / 1000;
     fpsCount++;
     return;
   }
   fpsCount++;
   long time = System.currentTimeMillis() / 1000;
   if (time != fpsTime) {
     lastFPS = fpsCount;
     fpsCount = 1;
     fpsTime = time;
   }
 }