imgcodecs: Add IMDecodeIntoMat to reduce heap allocations (#1035)

* imgcodecs: add IMDecodeIntoMat which allows to imdecode into existing Mat for performance
This commit is contained in:
Niklas Hansson
2022-12-01 10:14:30 +01:00
committed by deadprogram
parent 8f2aab1c67
commit cd9897f55d
4 changed files with 43 additions and 7 deletions

View File

@@ -42,3 +42,8 @@ Mat Image_IMDecode(ByteArray buf, int flags) {
cv::Mat img = cv::imdecode(data, flags);
return new cv::Mat(img);
}
void Image_IMDecodeIntoMat(ByteArray buf, int flags, Mat dest) {
std::vector<uchar> data(buf.data, buf.data + buf.length);
cv::imdecode(data, flags, dest);
}