SANE is an application programming interface (API) that provides standardized access to any raster image scanner hardware (flatbed scanner, hand-held scanner, video- and still-cameras, frame-grabbers, etc.).
You can also learn more about the SANE project through the official website
In the process of OpenHarmony's southward ecological development, it is necessary to be compatible with printers in the stock market. The use of CUPS printing system can directly connect with most printers in the market, which also reduces the difficulty for printer manufacturers to adapt to OpenHarmony.
- LICENSE Copyright File
- OAT.xml OAT.XML filtering configuration file
- README.OpenSource Project README OpenSource files
- README.md English Description
- README_zh.md Chinese Description
- backend scanning device backend source code
- include SANE API interface
- lib SANE library source code
- sanei SANE internal utility functions and tools
- doc documents and instruction files
#include <sane/sane.h>Add in the bundle. json file
"deps": {
"third_party": [
"backends"
]
}Add dependencies where needed in BUILD.gn
deps += [ "//third_party/backends:third_sane" ]SANE_Status status;
SANE_Handle handle;
// Initialize SANE
status = sane_init(NULL, NULL);
if (status != SANE_STATUS_GOOD) {
fprintf(stderr, "Failed to initialize SANE: %s\n", sane_strstatus(status));
return 1;
}
// Open the first scanner device
status = sane_open("your_scanner_device_name", &handle);
if (status != SANE_STATUS_GOOD) {
fprintf(stderr, "Failed to open scanner: %s\n", sane_strstatus(status));
return 1;
}
// Get scanner device information
const SANE_Device *device_info;
status = sane_get_devices(&device_info, SANE_FALSE);
if (status != SANE_STATUS_GOOD) {
fprintf(stderr, "Failed to get scanner device information: %s\n", sane_strstatus(status));
return 1;
}
// Set scan parameters
SANE_Parameters parameters;
status = sane_get_parameters(handle, ¶meters);
if (status != SANE_STATUS_GOOD) {
fprintf(stderr, "Failed to get scan parameters: %s\n", sane_strstatus(status));
return 1;
}
// Start scanning
SANE_Image image;
status = sane_start(handle);
if (status != SANE_STATUS_GOOD) {
fprintf(stderr, "Failed to start scanning: %s\n", sane_strstatus(status));
return 1;
}
// Read scan data
do {
status = sane_read(handle, &image);
if (status != SANE_STATUS_GOOD) {
fprintf(stderr, "Failed to read scan data: %s\n", sane_strstatus(status));
break;
}
} while (status == SANE_STATUS_GOOD);
// Finish scanning
status = sane_cancel(handle);
if (status != SANE_STATUS_GOOD) {
fprintf(stderr, "Failed to cancel scanning: %s\n", sane_strstatus(status));
return 1;
}
// Close the scanner device
status = sane_close(handle);
if (status != SANE_STATUS_GOOD) {
fprintf(stderr, "Failed to close scanner: %s\n", sane_strstatus(status));
return 1;
}
// Exit SANE
sane_exit();