@@ -5,17 +5,20 @@ import 'dart:typed_data';
5
5
6
6
import 'package:logging/logging.dart' ;
7
7
import 'package:sane/sane.dart' ;
8
+ import 'package:sane/src/impl/sane_dev.dart' ;
9
+ import 'package:sane/src/impl/sane_native.dart' ;
8
10
9
11
void main (List <String > args) async {
10
12
Logger .root.level = Level .ALL ;
11
13
Logger .root.onRecord.listen ((record) {
12
14
print ('${record .level .name }: ${record .time }: ${record .message }' );
13
15
});
14
16
15
- final sane = SaneNative (sane: SaneDev ());
16
- await sane.spawn ();
17
+ final sane = NativeSane (MockSane ());
17
18
18
- await sane.init ();
19
+ final version = await sane.initialize ();
20
+
21
+ print (version);
19
22
20
23
final devices = await sane.getDevices (localOnly: false );
21
24
for (final device in devices) {
@@ -26,40 +29,36 @@ void main(List<String> args) async {
26
29
return ;
27
30
}
28
31
29
- final handle = await sane. openDevice ( devices.first) ;
32
+ final device = devices.first;
30
33
31
- final optionDescriptors = await sane .getAllOptionDescriptors (handle );
34
+ final optionDescriptors = await device .getAllOptionDescriptors ();
32
35
33
36
for (final optionDescriptor in optionDescriptors) {
34
37
if (optionDescriptor.name == 'mode' ) {
35
- await sane.controlStringOption (
36
- handle: handle,
37
- index: optionDescriptor.index,
38
- action: SaneAction .setValue,
39
- value: 'Color' ,
38
+ await device.controlStringOption (
39
+ optionDescriptor.index,
40
+ SaneAction .setValue,
41
+ 'Color' ,
40
42
);
41
43
break ;
42
44
}
43
45
}
44
46
45
- await sane .start (handle );
47
+ await device .start ();
46
48
47
- final parameters = await sane .getParameters (handle );
49
+ final parameters = await device .getParameters ();
48
50
print ('Parameters: format(${parameters .format }), depth(${parameters .depth })' );
49
51
50
52
final rawPixelDataList = < Uint8List > [];
51
53
Uint8List ? bytes;
52
54
while (true ) {
53
- bytes = await sane .read (handle, parameters.bytesPerLine);
55
+ bytes = await device .read (bufferSize : parameters.bytesPerLine);
54
56
if (bytes.isEmpty) break ;
55
57
rawPixelDataList.add (bytes);
56
58
}
57
59
58
- await sane.cancel (handle);
59
- await sane.close (handle);
60
- await sane.exit ();
61
-
62
- sane.kill ();
60
+ await device.cancel ();
61
+ await device.close ();
63
62
64
63
Uint8List mergeUint8Lists (List <Uint8List > lists) {
65
64
final totalLength = lists.fold (0 , (length, list) => length + list.length);
0 commit comments