Created
August 26, 2019 13:13
-
-
Save StefanoBelli/fb65543553ce48dbd2744c513b3935e2 to your computer and use it in GitHub Desktop.
SANE API usage example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment