Results 1 to 7 of 7

Thread: C++ : how to implement SANE

  1. #1
    Join Date
    Nov 2015
    Beans
    10

    C++ : how to implement SANE

    hello,

    I'm trying to implement the SANE library under Ubuntu by following this example, it work but I would like to detect if a scanner has a document feeder and how to select it, I am also looking an example to retrieve the image in jpeg and not in pnm?

    Thanks

  2. #2
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: C++ : how to implement SANE

    Did you pull the sane-dev package with the source code? Is there a libsane-dev package? Why re-invent this wheel? If it were me, I'd leverage what other people have already done and just build the specific stuff on the earlier tools for my specific needs.

    The supported image formats will depend on the hardware. You can convert those to any other format you like. There are lots of tools to do that. convert (that's the program name), from the image-magick suite comes to mind. Any conversions can be hidden from the users.
    Last edited by TheFu; September 19th, 2021 at 03:32 PM.

  3. #3
    Join Date
    Oct 2017
    Location
    City of Waterfalls-Ph
    Beans
    Hidden!
    Distro
    Ubuntu 18.04 Bionic Beaver

    Re: C++ : how to implement SANE

    Quote Originally Posted by pol2095 View Post
    hello,
    I'm trying to implement the SANE library under Ubuntu by following this example, it work but I would like to detect if a scanner has a document feeder and how to select it, I am also looking an example to retrieve the image in jpeg and not in pnm?
    Thanks
    Hi I am using Xsane in my printer/scanner device under Linux Ubuntu 18 Operating System and it works smoothly.
    I am able to use jpeg format when I perform a scan to any of my documents. You just have to select some image
    format under xsane applications. I am not using any application software to convert some images that I get from
    my scanned document. Good luck and regards.
    corn ubuntuforums community.
    Open Source platform where the real world of human is here. Click here for Solve thread
    Rock n' Roll People.
    From: mike_08

  4. #4
    Join Date
    Nov 2015
    Beans
    10

    Re: C++ : how to implement SANE

    It's for integrate sane in my app, I don't need to use an other app...
    // SANE API usage example
    // link against libsane
    // --> http://www.sane-project.org/html/doc012.html
    #include <sane/sane.h>
    #include <stdio.h>


    int main() {
    //
    // Initialize SANE
    //
    SANE_Int version;
    sane_init(&version, NULL);

    //
    // Request SANE backend to perform device lookup
    // and retrieve a list
    //
    SANE_Device** devices;
    sane_get_devices((const SANE_Device***)&devices, 0);


    do {
    printf("found: %s\n", (*devices)->vendor);
    } while(*(++devices));


    devices--;

    //
    // Open selected devices, get an handle to that
    //
    SANE_Handle hnd;
    sane_open((*devices)->name, &hnd);

    //
    // Start scanning
    //
    sane_start(hnd);


    //
    // Read scanning data
    //
    SANE_Int len;
    SANE_Byte data[1024];
    sane_read(hnd, data, 1024, &len);


    printf("%d\n", len);

    //
    // We're done, cleanup...
    //
    sane_exit();

    return 0;
    }
    I need to convert "data" to jpeg ?
    Last edited by pol2095; September 18th, 2021 at 04:11 PM.

  5. #5
    Join Date
    Nov 2015
    Beans
    10

    Re: C++ : how to implement SANE

    I managed to make it work with the flatbed, but not using the feeder
    SANE_Parameters params.lines
    the feeder return a value 1100 (817 for the flatbed), it's the same page, the scanner display "scanning in progress" and the app crash ?
    Last edited by pol2095; September 19th, 2021 at 03:30 PM.

  6. #6
    Join Date
    Nov 2015
    Beans
    10

    Re: C++ : how to implement SANE

    I find a workaround.

  7. #7
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: C++ : how to implement SANE

    Quote Originally Posted by pol2095 View Post
    I find a workaround.
    Is it a big secret? Please share.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •