Menu

experiemntal gui and adf

Help
mauro
2009-10-22
2013-04-15
  • mauro

    mauro - 2009-10-22

    I am using the experimental GUI dialogs, i use the following code

    JSane_Base_Frame frame = JSane_Scan_Dialog.getScan( "127.0.0.1" , 6566 );

    if ( frame != null )
    {

    BufferedImage bi = frame.getImage( false );

    And this work quite well  when i scan a single image.
    My problem is: what code to use to manage the situation in which many images can come trough adf ?

    Thank you,
    Mauro

        

     
  • Andi McLean

    Andi McLean - 2009-10-23

    Currently there is no way to continually fetch images, like pages from the adf.

    Work on Jsane has come to a stop at the moment, as it was no longer needed and no-one else was putting in requests for additional improvements.

    If you need such functionality I would like to do start work again on JSane.

    What would you expect such a method to do?
    return an array/vector of frames? or perhaps you could pass in an object which inherits an interface which would be called when an frame is ready and only returning when no more pages are left or an error occurs.

    Let me know what you think.

    Andi

     
  • mauro

    mauro - 2009-10-23

    I need to be able to acquire images from within a java web application.
    The client PCs of the web app are both windows and linux clients.
    So i developed an applet and in the linux case the idea is to control the scanner through jsane.
    If you can suggest a better option i will evaluate it, but i also need to develop something
    urgently, so if possible i'll continue with JSane. ADF should also be supported.

    I just looked into the 

    public static JSane_Base_Frame getScan( String hostname , int port )

    method within the JSane_Scan_Dialog class.

    These statements

    // code start

    JSane_Net_Connection connection = new JSane_Net_Connection( hostname , port );

    device = JSane_Swing_Device_Dialog.getDevice( connection );

    JSane_Base_Frame frame = getScan( device );

    connection.exit();

    // code end

    are interesting to me because i think they could be extended to support ADF.

    The extension i suppose to work is the following, unfortunately i have not an adf scanner to test
    it

    // code start

    JSane_Net_Connection connection = new JSane_Net_Connection( "127.0.0.1" , 6566 );

    JSane_Base_Device device = JSane_Swing_Device_Dialog.getDevice( connection );

    JSane_Base_Frame frame = JSane_Scan_Dialog.getScan( device );

    if ( frame != null )
    {

    BufferedImage bi = frame.getImage( false );

    // .. write image to disk

    while (true)
    {

    try
    {
    frame = device.getFrame();

    }
    catch (Exception ex)
    {
    break;
    }

    if (frame == null) break;

    bi = frame.getImage( false );

    // .. write image to disk

    }
    }

    connection.exit();

    // code end

    So first of all i would like to know if you think this could work (i think it should work because
    of your comment to this message in 'feature requests')

    http://sourceforge.net/tracker/?func=detail&aid=1220185&group_id=95639&atid=612101.

    Of course further enhancements of JSane could also be useful, for instance this method

    JSane_Base_Frame frame = JSane_Scan_Dialog.getScan( device );

    could be generalized to return an array of frames.

    Thank you,
    Mauro

     
  • Andi McLean

    Andi McLean - 2009-10-26

    I believe your code should work.

    The gui was only written to provide a base to work on and is waiting for suggestions to make it better.

    The JSane_Scan_Dialog(device) should be extened to return an array of frames, but this does have a problem with memory usage, the images returned can be very large, as it is raw pixel data.

    Another option is to have a version of getScan() that can take an object that can be called for each image processed.

    That way the calling method can decide if it wants to keep a pointer to the image or save/process it further.

    Andi

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.