熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> Javascript >> 正文

如何用 java 編寫一個掃描儀程序

2022-06-13   來源: Javascript 

  javatwain may be a powerful solutionyou can go to wwwgnomesk to download the newest package
   JavaTwain version is a part of the Morena Framework now
  
   below is an simple example:
   /*
   * $Id: ExampleShowjavav // :: mmotovsk Exp $
   *
   * Copyright (c) Gnome spol s ro All Rights Reserved
   *
   * This software is the confidential and proprietary information of
   * Gnome spol s ro You shall not disclose such Confidential
   * Information and shall use it only in accordance with the terms
   * of the license agreement you entered into with Gnome
   */
  
  // JavaTwain package version
  
  /**
   ExampleShow demonstrates how to scan an image using defaults
   from the Twain source <BR>
  */
  
  import javaawt*;
  import javaawtevent*;
  import SKgnometwain*;
  
  public class ExampleShow extends Frame
  { Image image;
   public void paint(Graphics g) 
   { if (null!=image)
     gdrawImage(image this);
   }
   
   WindowListener windowAdapter=new WindowAdapter()
   { public void windowClosing(WindowEvent e)
    { Systemexit();
    }
   };
   
   public ExampleShow()
   { try
    { addWindowListener(windowAdapter);
     setTitle(ExampleShow Frame Application);
     // Open TWAIN select source dialog box
     // and initialize the source selected by the user
     TwainSource source=TwainManagerselectSource(null);
     image=ToolkitgetDefaultToolkit()createImage(source);
     // wait for the image to be completed
     MediaTracker tracker=new MediaTracker(this);
     trackeraddImage(image );
     // this is the moment the scanner user interface pops up
     Systemerrprintln(Start loading image );
     try
     { trackerwaitForAll();
     }
     catch (InterruptedException e)
     { Systemerrprintln(Image loading was interrupted!);
      eprintStackTrace();
     }
     trackerremoveImage(image);
     Systemerrprintln(Image loaded );
     setSize(imagegetWidth(this) imagegetHeight(this));
     setVisible(true);
     TwainManagerclose();
    }
    catch (TwainException e)
    { eprintStackTrace();
    }
   }
   
   public static void main(String[] args)
   { new ExampleShow();
   }
  }
From:http://tw.wingwit.com/Article/program/Java/Javascript/201311/25319.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.