如何从打印机“扫描仪”获取图像

时间:2013-06-24 01:11:28

标签: java image file image-scanner

我想通过使用java代码从打印机“Scanner”获取图像,在获取图像后我想将其保存在项目文件夹中,我该怎么做?

 public static void main(String args[]) {
    }

2 个答案:

答案 0 :(得分:2)

也许你可以看看这个framework

答案 1 :(得分:2)

试试这个,

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

参考:http://asprise.com/product/jtwain/faq.php