顾海波

【修复】旋转

... ... @@ -255,6 +255,12 @@ class IProcessingCameraImage implements ProcessingCameraImage {
}
rotationAngle ??= 0;
double rad =
(rotationAngle * 3.14159265358979323846264338327950288 / 180.0);
double sinVal = sin(rad).abs();
double cosVal = cos(rad).abs();
int newImgWidth = (sinVal * height + cosVal * width).toInt();
int newImgHeight = (sinVal * width + cosVal * height).toInt();
Pointer<Uint8> p = ffi.malloc.allocate(plane0.length);
... ... @@ -263,19 +269,19 @@ class IProcessingCameraImage implements ProcessingCameraImage {
Pointer<Uint32> imgP = _convertImageNV21ToRGB(
p,
width,
height,
newImgWidth,
newImgHeight,
rotationAngle,
backGroundColor,
isFlipVectical,
isFlipHoriozntal,
);
final imgData = imgP.asTypedList(width * height);
final imgData = imgP.asTypedList(newImgWidth * newImgHeight);
imglib.Image img = imglib.Image.fromBytes(
bytes: imgData.buffer,
width: width,
height: height,
width: newImgWidth,
height: newImgHeight,
order: imglib.ChannelOrder.rgba);
ffi.malloc.free(p);
... ...