From 93a337c4ab4172b5e8ad429b841949c715338c47 Mon Sep 17 00:00:00 2001 From: Marino von Wattenwyl Date: Fri, 27 Oct 2023 11:26:26 +0200 Subject: [PATCH] [Android] Fix HDR image loading --- modules/cv/source/CVImage.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/modules/cv/source/CVImage.cpp b/modules/cv/source/CVImage.cpp index ca9d64b4..6f199011 100644 --- a/modules/cv/source/CVImage.cpp +++ b/modules/cv/source/CVImage.cpp @@ -387,12 +387,11 @@ void CVImage::load(const string& filename, // load the image format as stored in the file - SLIOBuffer buffer = SLFileStorage::readIntoBuffer(filename, IOK_image); - CVMat inputMat = CVMat(1, (int)buffer.size, CV_8UC1, buffer.data); - #ifndef __EMSCRIPTEN__ - _cvMat = cv::imdecode(inputMat, cv::ImreadModes::IMREAD_UNCHANGED); + _cvMat = cv::imread(filename, cv::ImreadModes::IMREAD_UNCHANGED); #else + SLIOBuffer buffer = SLFileStorage::readIntoBuffer(filename, IOK_image); + unsigned char* encodedData = buffer.data; int size = (int)buffer.size; int width; @@ -401,9 +400,9 @@ void CVImage::load(const string& filename, stbi_hdr_to_ldr_gamma(1.0f); unsigned char* data = stbi_load_from_memory(encodedData, size, &width, &height, &numChannels, 0); _cvMat = CVMat(height, width, CV_8UC(numChannels), data); -#endif SLFileStorage::deleteBuffer(buffer); +#endif if (!_cvMat.data) {