Forums › TWAIN Classic › From Java with user interface Twain › Reply To: From Java with user interface Twain
Hi!, I’m actually working with Java and I want to use Twain but I only want to scan from a scanner with a sets of parameters (Color, 300dpi). How can I do this without the user interfaze of Twain, only into a call to any function???
If you decide to use Morena Image Acquisition Framework for Java (http://www.gnome.sk), you can hide Twain User Interface window by calling setVisible(false) method of the TwainSource class. And then set all capabiities directly from your application. (It could happend, that setVisible method will be not implemented by the Twain driver.)
Here is a snapshot demonstrating how to do it:
TwainSource source = TwainManager.selectSource(null);
source.setVisible(false);
source.setColorMode();
source.setResolution(300);
MorenaImage morenaImage = new MorenaImage(source);
Image image=Toolkit.getDefaultToolkit().createImage(morenaImage);
TwainManager.close();
Now I have another problem. I want to scan in duplex mode and I don’t know how to capture the two images. Can you help me???.
Using Morena you can use the following code design:
TwainSource source=TwainManager.selectSource(null);
if (source!=null)
{
source.setDuplexEnabled(true);
source.setFeederEnabled(true);
source.setAutoFeed(true);
source.setTransferCount(-1);
int count=1;
do
{ MorenaImage image=new MorenaImage(source);
System.err.println("Size of acquired image "+(count++)+" is "
+image.getWidth()+" x "
+image.getHeight()+" x "
+image.getPixelSize());
}
while (source.hasMoreImages());
}
TwainManager.close();
Martin Motovsky
Member of Gnome’s technical support