Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions tools/imageio/exr.imageio/exrinput.cc
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ void ExrInput::readImage(void* outputBuffer, size_t bufferByteCount,
" images for each face and use those to create your KTX file.");
}
}
if (header.tiled && header.tile_level_mode != TINYEXR_TILE_ONE_LEVEL)
throw std::runtime_error(fmt::format("Multi-level tiled EXR images are not supported."));
if ((header.tiled && image.tiles == nullptr) || (!header.tiled && image.images == nullptr))
throw std::runtime_error(fmt::format("Invalid EXR file. {}",
header.tiled ? "Tiled with no tiles" : "scanline with no images."));
Expand Down Expand Up @@ -297,11 +299,12 @@ void ExrInput::readImage(void* outputBuffer, size_t bufferByteCount,
};

for(int32_t tile = 0; tile < image.num_tiles; ++tile) {
for (int32_t ty = 0; ty < header.tile_size_y; ++ty) {
for (int32_t tx = 0; tx < header.tile_size_x; ++tx) {
for (int32_t ty = 0; ty < image.tiles[tile].height; ++ty) {
for (int32_t tx = 0; tx < image.tiles[tile].width; ++tx) {
auto x = image.tiles[tile].offset_x * header.tile_size_x + tx;
auto y = image.tiles[tile].offset_y * header.tile_size_y + ty;
auto* targetPixel = ptr + (y * width * numTargetChannels + x * numTargetChannels) * dataSize;
assert(targetPixel < ptr + bufferByteCount && "outputBuffer overrun loading tiled .exr");
for (uint32_t c = 0; c < numTargetChannels; ++c) {
if (channels[c].has_value()) {
std::memcpy(targetPixel + c * dataSize, sourcePtr(*channels[c], tile, tx, ty), dataSize);
Expand All @@ -323,6 +326,7 @@ void ExrInput::readImage(void* outputBuffer, size_t bufferByteCount,
for (uint32_t y = 0; y < height; ++y) {
for (uint32_t x = 0; x < width; ++x) {
auto* targetPixel = ptr + (y * width * numTargetChannels + x * numTargetChannels) * dataSize;
assert(targetPixel < ptr + bufferByteCount && "outputBuffer overrun loading scanline .exr");
for (uint32_t c = 0; c < numTargetChannels; ++c) {
if (channels[c].has_value()) {
std::memcpy(targetPixel + c * dataSize, sourcePtr(*channels[c], x, y), dataSize);
Expand Down
Loading