Status: New
Owner: ----
Labels: Type-Defect Priority-Medium
New issue 9 by
syedalia...@gmail.com: jfreesane fails to provide the
buffered java image and shows and index out of Bounds error
http://code.google.com/p/jfreesane/issues/detail?id=9
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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
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();
}// </editor-fold>
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();
// Logger.getLogger(TestJfree.class.getName()).log(Level.SEVERE,
null, ex);
}catch(Exception ex){
System.out.println("General Exception:"+ex.toString());
System.out.println("");
System.out.println("");
System.out.println("");
System.out.println("");
ex.printStackTrace();
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel
setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with
the default look and feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(TestJfree.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(TestJfree.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(TestJfree.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(TestJfree.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new TestJfree().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
// End of variables declaration
}
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings