Skip to content

Commit

Permalink
[Android] Fix HDR image loading
Browse files Browse the repository at this point in the history
  • Loading branch information
chnoblouch committed Oct 27, 2023
1 parent 4da0f26 commit 93a337c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions modules/cv/source/CVImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
{
Expand Down

0 comments on commit 93a337c

Please sign in to comment.