0

I want to get image from printer "Scanner" by using java code , and after get image i want to save it on project folder , How i can do that ?

 public static void main(String args[]) {
    }
Abdullah Alhazmy
  • 587
  • 2
  • 7
  • 19
  • Windows , NetBeans :) – Abdullah Alhazmy Jun 24 '13 at 01:17
  • Are you aware that `Scanner` will help you to get the user input and not an image, right? Also, NetBeans is just a tool that helps you create Java applications. – Luiggi Mendoza Jun 24 '13 at 01:18
  • yes , i know netbeans it`s a tool , and i mean by "scanner" the device that use to scan the image , NOT scanner class :) – Abdullah Alhazmy Jun 24 '13 at 01:24
  • 1
    You're going to need a native interface to talk to the scanner via what ever driver implementation the scanner supports. Under Windows, the two primary protocols are TWAIN and WIA. Personally, I'd recommend [Morena](http://www.gnome.sk/Morena/morena.html), mostly because it has a nice "personal" use license which I've used a lot – MadProgrammer Jun 24 '13 at 01:28
  • I strongly disagree, that this question should be closed. It is rather seldom topic, and most of java programmers know nothing of it, and don't know where to get any info. So do I. – Dmitry Bakhtiarov Apr 13 '17 at 19:17

2 Answers2

3

Maybe you can take a look at this framework.

jh314
  • 27,144
  • 16
  • 62
  • 82
2

try this,

 try {

        Source source = SourceManager.instance().getDefaultSource(); 
        // Acquire image from default source
        source.open();

        Image image = source.acquireImage(); // Acquire the image

        // Loads the image completely ...
        // Click here to find how to load images completely with MediaTracker.
        // ...

        int imageWidth = image.getWidth(this);
        int imageHeight = image.getHeight(this);

        BufferedImage bufferedImage = new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_RGB);

        Graphics2D g2 = bufferedImage.createGraphics();
        g2.drawImage(image, 0, 0, this);

        // Now, you can use the bufferedImage object ...

    }catch(Exception e) {
        e.printStackTrace();
    }finally{
        SourceManager.closeSourceManager();
    } 

Reference : http://asprise.com/product/jtwain/faq.php

newuser
  • 8,338
  • 2
  • 25
  • 33