2024-08-12 10:22:05 +08:00
2023-01-27 18:09:57 -05:00
2023-02-04 09:40:07 -08:00
2019-12-14 08:13:54 +00:00
2019-07-14 17:08:08 +09:00
2020-03-05 21:14:34 +09:00
2023-02-04 19:01:14 -08:00
2020-08-29 09:18:04 +02:00
2021-01-24 06:24:53 +00:00
2019-06-30 12:45:03 +09:00

SANE

Introduction

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

Background Brief

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.

Directory structure

- 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

How to use

1、Header file import

#include <sane/sane.h>

2、Add Compilation Dependency

Add in the bundle. json file

"deps": {
  "third_party": [
    "backends"
  ]
}

Add dependencies where needed in BUILD.gn

deps += [ "//third_party/backends:third_sane" ]

3、Example of interface usage

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, &parameters);
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();

相关仓

print_print_fwk

参与贡献

How to involve

Commit message spec

S
Description
No description provided
Readme 49 MiB
Languages
C 90.1%
C++ 8.4%
Makefile 0.5%
Java 0.4%
M4 0.4%
Other 0.1%