-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
decoder.dart
32 lines (24 loc) · 807 Bytes
/
decoder.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import 'package:collection/collection.dart';
import 'package:image_size_getter/src/core/size.dart';
import 'package:image_size_getter/src/entity/block_entity.dart';
import 'package:image_size_getter/src/core/input.dart';
part 'gif_decoder.dart';
part 'jpeg_decoder.dart';
part 'png_decoder.dart';
part 'webp_decoder.dart';
abstract class AsyncImageDecoder {
AsyncImageDecoder(this.input);
final AsyncImageInput input;
Future<Size> get size;
int convertRadix16ToInt(List<int> list, {bool reverse = false}) {
final sb = StringBuffer();
if (reverse) {
list = list.toList().reversed.toList();
}
for (final i in list) {
sb.write(i.toRadixString(16).padLeft(2, '0'));
}
final numString = sb.toString();
return int.tryParse(numString, radix: 16) ?? 0;
}
}