decodeImageInfos function
Future<ImageInfos>
decodeImageInfos({
- required Uint8List bytes,
- required Size screenSize,
- TransformConfigs? configs,
Decode the image being edited.
Implementation
Future<ImageInfos> decodeImageInfos({
required Uint8List bytes,
required Size screenSize,
TransformConfigs? configs,
}) async {
var decodedImage = await decodeImageFromList(bytes);
bool rotated = configs?.is90DegRotated == true;
int w = decodedImage.width;
int h = decodedImage.height;
if (configs != null && configs.isNotEmpty) {
w = w ~/ configs.scaleUser;
h = h ~/ configs.scaleUser;
}
double widthRatio = (rotated ? h : w).toDouble() / screenSize.width;
double heightRatio = (rotated ? w : h).toDouble() / screenSize.height;
double pixelRatio = max(heightRatio, widthRatio);
Size renderedSize =
Size(w.toDouble() / pixelRatio, h.toDouble() / pixelRatio);
return ImageInfos(
rawSize: Size(w.toDouble(), h.toDouble()),
renderedSize: renderedSize,
cropRectSize: configs != null && configs.isNotEmpty
? configs.cropRect.size
: renderedSize,
pixelRatio: pixelRatio,
isRotated: configs?.is90DegRotated ?? false,
);
}