科技行者

行者学院 转型私董会 科技行者专题报道 网红大战科技行者

知识库

知识库 安全导航

至顶网软件频道如何用 java 编写一个扫描仪程序

如何用 java 编写一个扫描仪程序

  • 扫一扫
    分享文章到微信

  • 扫一扫
    关注官方公众号
    至顶头条

  javatwain may be a powerful solution,you can go to www.gnome.sk to download the newest package.    JavaTwain version 5.1 is

作者:中国IT实验室 来源:中国IT实验室 2007年9月25日

关键字: 编程 java

  • 评论
  • 分享微博
  • 分享邮件

  javatwain may be a powerful solution,you can go to www.gnome.sk to download the newest package.
   JavaTwain version 5.1 is a part of the Morena 6.0 Framework now.
  
   below is an simple example:
   /*
   * $Id: ExampleShow.java,v 1.5 2002/07/15 13:48:55 mmotovsk Exp $
   *
   * Copyright (c) 1999-2002 Gnome spol. s r.o. All Rights Reserved.
   *
   * This software is the confidential and proprietary information of
   * Gnome spol. s r.o. 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 5.1
  
  /**
   ExampleShow demonstrates how to scan an image using defaults
   from the Twain source. <BR>
  */
  
  import java.awt.*;
  import java.awt.event.*;
  import SK.gnome.twain.*;
  
  public class ExampleShow extends Frame
  { Image image;
   public void paint(Graphics g) 
   { if (null!=image)
     g.drawImage(image, 0, 0, this);
   }
   
   WindowListener windowAdapter=new WindowAdapter()
   { public void windowClosing(WindowEvent e)
    { System.exit(0);
    }
   };
   
   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=TwainManager.selectSource(null);
     image=Toolkit.getDefaultToolkit().createImage(source);
     // wait for the image to be completed
     MediaTracker tracker=new MediaTracker(this);
     tracker.addImage(image, 0);
     // this is the moment the scanner user interface pops up
     System.err.println("Start loading image ...");
     try
     { tracker.waitForAll();
     }
     catch (InterruptedException e)
     { System.err.println("Image loading was interrupted!");
      e.printStackTrace();
     }
     tracker.removeImage(image);
     System.err.println("Image loaded ...");
     setSize(image.getWidth(this), image.getHeight(this));
     setVisible(true);
     TwainManager.close();
    }
    catch (TwainException e)
    { e.printStackTrace();
    }
   }
   
   public static void main(String[] args)
   { new ExampleShow();
   }
  }

查看本文来源

    • 评论
    • 分享微博
    • 分享邮件
    邮件订阅

    如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。

    重磅专题
    往期文章
    最新文章