getSizeAsync method
Returns the size of the input
.
Implementation
@override
Future<Size> getSizeAsync(AsyncImageInput input) async {
int start = 2;
BlockEntity? block;
var orientation = 1;
while (true) {
block = await _getBlockAsync(input, start);
if (block == null) {
throw Exception('Invalid jpeg file');
}
if (block.type == 0xE1) {
final app1BlockData = await input.getRange(
start,
block.start + block.length,
);
final exifOrientation = _getOrientation(app1BlockData);
if (exifOrientation != null) {
orientation = exifOrientation;
}
}
if (block.type == 0xC0 || block.type == 0xC2) {
final widthList = await input.getRange(start + 7, start + 9);
final heightList = await input.getRange(start + 5, start + 7);
orientation = (await input.getRange(start + 9, start + 10))[0];
return _getSize(widthList, heightList, orientation);
} else {
start += block.length;
}
}
}