@@ -5,17 +5,20 @@ import 'dart:typed_data';
55
66import 'package:logging/logging.dart' ;
77import 'package:sane/sane.dart' ;
8+ import 'package:sane/src/impl/sane_dev.dart' ;
9+ import 'package:sane/src/impl/sane_native.dart' ;
810
911void main (List <String > args) async {
1012 Logger .root.level = Level .ALL ;
1113 Logger .root.onRecord.listen ((record) {
1214 print ('${record .level .name }: ${record .time }: ${record .message }' );
1315 });
1416
15- final sane = SaneNative (sane: SaneDev ());
16- await sane.spawn ();
17+ final sane = NativeSane (MockSane ());
1718
18- await sane.init ();
19+ final version = await sane.initialize ();
20+
21+ print (version);
1922
2023 final devices = await sane.getDevices (localOnly: false );
2124 for (final device in devices) {
@@ -26,40 +29,36 @@ void main(List<String> args) async {
2629 return ;
2730 }
2831
29- final handle = await sane. openDevice ( devices.first) ;
32+ final device = devices.first;
3033
31- final optionDescriptors = await sane .getAllOptionDescriptors (handle );
34+ final optionDescriptors = await device .getAllOptionDescriptors ();
3235
3336 for (final optionDescriptor in optionDescriptors) {
3437 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' ,
4042 );
4143 break ;
4244 }
4345 }
4446
45- await sane .start (handle );
47+ await device .start ();
4648
47- final parameters = await sane .getParameters (handle );
49+ final parameters = await device .getParameters ();
4850 print ('Parameters: format(${parameters .format }), depth(${parameters .depth })' );
4951
5052 final rawPixelDataList = < Uint8List > [];
5153 Uint8List ? bytes;
5254 while (true ) {
53- bytes = await sane .read (handle, parameters.bytesPerLine);
55+ bytes = await device .read (bufferSize : parameters.bytesPerLine);
5456 if (bytes.isEmpty) break ;
5557 rawPixelDataList.add (bytes);
5658 }
5759
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 ();
6362
6463 Uint8List mergeUint8Lists (List <Uint8List > lists) {
6564 final totalLength = lists.fold (0 , (length, list) => length + list.length);
0 commit comments