如何用java编写扫描仪程序

王朝java/jsp·作者佚名  2008-05-19
宽屏版  字体: |||超大  

Q:我想用Java开发一个程序,直接从扫描仪获得扫描数据,然后上载到服务器上,这样的程序需要利用那些知识点(有关Java)?

RE:

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.

*/

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();

}

}

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有