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();
}
}
闽公网安备 35060202000074号