Beispiel #1
0
  public static void main(String[] args) {
    try {
      // non-throwing message printer
      Kdu_sysout_message sysout = new Kdu_sysout_message(false);
      // exception-throwing message printer
      Kdu_sysout_message syserr = new Kdu_sysout_message(true);
      // non-throwing formatted printer
      Kdu_message_formatter formattedSysout = new Kdu_message_formatter(sysout);
      // throwing formatted printer
      Kdu_message_formatter formattedSyserr = new Kdu_message_formatter(syserr);

      Kdu_global.Kdu_customize_warnings(formattedSysout);
      Kdu_global.Kdu_customize_errors(formattedSyserr);
    } catch (KduException e) {
      System.err.printf("Exception during Kdu stream tie: %s\n", e.getMessage());
    }

    if (args.length != 1) {
      System.err.println("You must supply a filename (JP2, JPX or raw code-stream)");
      System.exit(0);
    }

    final String filename = args[0];

    SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {
            Haikdu app = new Haikdu(filename);
          }
        });
  }
Beispiel #2
0
  public void render() {
    try {
      int regionBufferSize = 0;
      int[] regionBuffer = null;
      Kdu_dims newRegion = new Kdu_dims();

      long kduRenderStart = System.nanoTime();

      while (compositor.Process(100000, newRegion)) {
        Kdu_coords newOffset = newRegion.Access_pos();
        Kdu_coords newSize = newRegion.Access_size();

        newOffset.Subtract(viewDims.Access_pos());

        int newPixels = newSize.Get_x() * newSize.Get_y();
        if (newPixels == 0) continue;
        else if (newPixels > regionBufferSize) {
          regionBufferSize = newPixels;
          regionBuffer = new int[regionBufferSize];
        }

        compositorBuffer.Get_region(newRegion, regionBuffer);
        imagePanel.putRegion(
            viewSize.Get_x(),
            viewSize.Get_y(),
            newSize.Get_x(),
            newSize.Get_y(),
            newOffset.Get_x(),
            newOffset.Get_y(),
            regionBuffer);
      }

      long kduRenderEnd = System.nanoTime();

      System.out.printf(
          "Processed using %d concurrent threads of execution in %.4fms\n",
          threadEnv.Get_num_threads(), (kduRenderEnd - kduRenderStart) * 1e-6);
      imagePanel.repaint();
    } catch (KduException e) {
      System.err.printf(
          "Caught exception '%s'; code '%s'\n",
          e.getMessage(), Integer.toHexString(e.Get_kdu_exception_code()));
    }
  }