Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jfreesane fails to provide the buffered java image and shows and index out of Bounds error #9

Closed
sjamesr opened this issue Jan 4, 2014 · 3 comments

Comments

@sjamesr
Copy link
Owner

sjamesr commented Jan 4, 2014

From syedalia...@gmail.com on December 19, 2013 00:32:24

I tried jfreesane on HP scanjet200 (sane version is 1.0.18)

it fails with the following error (after the scanner completes its scanning cycle

[siguser@T24-Client t24scan2]$ sh doscan.sh
Entered
hp200:libusb:001:010
General Exception:java.lang.IndexOutOfBoundsException

java.lang.IndexOutOfBoundsException
at java.io.InputStream.read(Unknown Source)
at au.com.southsky.jfreesane.SaneSession$FrameInputStream.readRecord(SaneSession.java:338)
at au.com.southsky.jfreesane.SaneSession$FrameInputStream.readFrame(SaneSession.java:286)
at au.com.southsky.jfreesane.SaneSession.acquireImage(SaneSession.java:185)
at au.com.southsky.jfreesane.SaneDevice.acquireImage(SaneDevice.java:90)
at t24scan.TestJfree.jButton1ActionPerformed(TestJfree.java:87)
at t24scan.TestJfree.access$000(TestJfree.java:22)
at t24scan.TestJfree$1.actionPerformed(TestJfree.java:47)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
d(SaneSession.java:338)

my test code is
package t24scan;
import au.com.southsky.jfreesane.SaneDevice;
import au.com.southsky.jfreesane.SaneException;
import au.com.southsky.jfreesane.SaneSession;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.*;
import java.net.InetAddress;
import java.net.Socket;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;

/**
*

  • @author sahmad02
    */
    public class TestJfree extends javax.swing.JFrame {

    /**

    • Creates new form TestJfree
      */
      public TestJfree() {
      initComponents();
      }

    /**

    • This method is called from within the constructor to initialize the form.

    • WARNING: Do NOT modify this code. The content of this method is always

    • regenerated by the Form Editor.
      */
      @SuppressWarnings("unchecked")
      //
      private void initComponents() {

      jButton1 = new javax.swing.JButton();

      setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

      jButton1.setText("Scan");
      jButton1.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
      jButton1ActionPerformed(evt);
      }
      });

      javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
      getContentPane().setLayout(layout);
      layout.setHorizontalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(layout.createSequentialGroup()
      .addGap(108, 108, 108)
      .addComponent(jButton1)
      .addContainerGap(237, Short.MAX_VALUE))
      );
      layout.setVerticalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(layout.createSequentialGroup()
      .addGap(111, 111, 111)
      .addComponent(jButton1)
      .addContainerGap(166, Short.MAX_VALUE))
      );

      pack();
      }//

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    try {
    // TODO add your handling code here:

        InetAddress address = InetAddress.getByName("127.0.0.1");
         Socket theSocket = new Socket(address, 6566);
        SaneSession session = SaneSession.withRemoteSane(theSocket.getInetAddress());
    
        List<SaneDevice> devices = session.listDevices();
        for(int u=0;u<devices.size();u++){
            System.out.println(devices.get(u).getName());
        }
        SaneDevice device=null;
        device=session.getDevice(devices.get(0).getName());
        if (!device.isOpen()){
            device.open();
            BufferedImage image =  device.acquireImage();
            File outputfile = new File("saved.jpg");
            ImageIO.write(image, "jpg", outputfile);
        }
    
    
    
    } catch (SaneException ex) {
        System.out.println("Sane Exception:"+ex.toString());
        System.out.println("");
        System.out.println("");
        System.out.println("");
        ex.printStackTrace();
       // ...
    

Original issue: http://code.google.com/p/jfreesane/issues/detail?id=9

@sjamesr
Copy link
Owner Author

sjamesr commented Jan 4, 2014

From syedalia...@gmail.com on December 19, 2013 00:33:31

Any help is more than welcome here

@sjamesr
Copy link
Owner Author

sjamesr commented Jan 4, 2014

From s...@jdns.org on December 21, 2013 13:42:23

Which version of jfreesane are you using? Can you try using the latest from source?

@sjamesr
Copy link
Owner Author

sjamesr commented Dec 19, 2014

Please feel free to reopen if you still have the issue.

@sjamesr sjamesr closed this as completed Dec 19, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant