I am trying to scan an image and save it to a file based on a specific format (Tiff or Jpeg) using the Swing application using Morena and Sane.
I load the entire image into memory using this process:
SaneSource source = ; MorenaImage morenaImage = new MorenaImage(source); Image image=Toolkit.getDefaultToolkit().createImage(morenaImage); BufferedImage bimg = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); Graphics2D g = bimg.createGraphics(); g.drawImage(image, 0, 0, null); ImageIO.write(bimg, "jpg", new File(filename));
I am sure that there is a better way to do this without eating all of my memory, for example, streaming the contents of my scanned image in a cache with a file using Consumer / Observer, but I could not recoup my mind enough around these concepts to create my own solution.
Could you help me along the way of improving image processing? Thanks in advance, david
source share