Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sylikc committed Sep 23, 2023
2 parents d27ee21 + db294bf commit fdd8da1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
15 changes: 5 additions & 10 deletions src/JPEGView/HEIFWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,16 @@ void * HeifReader::ReadImage(int &width,
}
std::vector<uint8_t> iccp = image.get_raw_color_profile();
void* transform = ICCProfileTransform::CreateTransform(iccp.data(), iccp.size(), ICCProfileTransform::FORMAT_RGBA);
uint8_t* p;
size_t i, j;
if (!ICCProfileTransform::DoTransform(transform, data, pPixelData, width, height, stride=stride)) {
memcpy(pPixelData, data, size);
unsigned char* o = pPixelData;
unsigned int* o = (unsigned int*)pPixelData;
for (i = 0; i < height; i++) {
p = data + i * stride;
unsigned int* p = (unsigned int*)(data + i * stride);
for (j = 0; j < width; j++) {
// RGBA -> BGRA conversion
o[0] = p[2];
o[1] = p[1];
o[2] = p[0];
o[3] = p[3];
p += nchannels;
o += nchannels;
*o = _rotr(_byteswap_ulong(*p), 8);
p++;
o++;
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/JPEGView/JXLWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,11 @@ void* JxlReader::ReadImage(int& width,
if (cache.transform == NULL)
cache.transform = ICCProfileTransform::CreateTransform(icc_profile.data(), icc_profile.size(), ICCProfileTransform::FORMAT_RGBA);
if (!ICCProfileTransform::DoTransform(cache.transform, pixels.data(), pPixelData, width, height)) {
memcpy(pPixelData, pixels.data(), size);
// RGBA -> BGRA conversion (with little-endian integers)
for (uint32_t* i = (uint32_t*)pPixelData; (uint8_t*)i < pPixelData + size; i++)
*i = ((*i & 0x00FF0000) >> 16) | ((*i & 0x0000FF00)) | ((*i & 0x000000FF) << 16) | ((*i & 0xFF000000));
uint32_t* data = (uint32_t*)pixels.data();
for (int i = 0; i * sizeof(uint32_t) < size; i++) {
((uint32_t*)pPixelData)[i] = _rotr(_byteswap_ulong(data[i]), 8);
}
}

// Copy Exif data into the format understood by CEXIFReader
Expand Down

0 comments on commit fdd8da1

Please sign in to comment.