diff --git a/src/psd.imageio/psdinput.cpp b/src/psd.imageio/psdinput.cpp index 98256f297..033cb29d3 100644 --- a/src/psd.imageio/psdinput.cpp +++ b/src/psd.imageio/psdinput.cpp @@ -1892,6 +1892,8 @@ PSDInput::load_image_data() // setup some generic properties and read any RLE lengths // Image Data Section has RLE lengths for all channels stored first for (ChannelInfo& channel_info : m_image_data.channel_info) { + channel_info.width = m_header.width; + channel_info.height = m_header.height; channel_info.compression = compression; channel_info.channel_id = id++; channel_info.data_length = row_length * m_header.height; @@ -2047,39 +2049,39 @@ PSDInput::read_channel_row(ChannelInfo& channel_info, uint32_t row, char* data) case 16: swap_endian((uint16_t*)data, channel_info.width); break; case 32: swap_endian((uint32_t*)data, channel_info.width); break; } - break; - case Compression_RLE: { - if (!ioseek(channel_info.row_pos[row])) - return false; - uint32_t rle_length = channel_info.rle_lengths[row]; - char* rle_buffer; - OIIO_ALLOCATE_STACK_OR_HEAP(rle_buffer, char, rle_length); - if (!ioread(rle_buffer, rle_length) - || !decompress_packbits(rle_buffer, data, rle_length, - channel_info.row_length)) - return false; - } break; - case Compression_ZIP: { - OIIO_ASSERT(channel_info.decompressed_data.size() - == static_cast(channel_info.width) - * channel_info.height * (m_header.depth / 8)); - // We simply copy over the row into destination - uint64_t row_index = static_cast(row) * channel_info.width - * (m_header.depth / 8); - std::memcpy(data, channel_info.decompressed_data.data() + row_index, - channel_info.row_length); - } break; - case Compression_ZIP_Predict: { - OIIO_ASSERT(channel_info.decompressed_data.size() - == static_cast(channel_info.width) - * channel_info.height * (m_header.depth / 8)); - // We simply copy over the row into destination - uint64_t row_index = static_cast(row) * channel_info.width - * (m_header.depth / 8); - std::memcpy(data, channel_info.decompressed_data.data() + row_index, - channel_info.row_length); - } break; } + break; + case Compression_RLE: { + if (!ioseek(channel_info.row_pos[row])) + return false; + uint32_t rle_length = channel_info.rle_lengths[row]; + char* rle_buffer; + OIIO_ALLOCATE_STACK_OR_HEAP(rle_buffer, char, rle_length); + if (!ioread(rle_buffer, rle_length) + || !decompress_packbits(rle_buffer, data, rle_length, + channel_info.row_length)) + return false; + } break; + case Compression_ZIP: { + OIIO_ASSERT(channel_info.decompressed_data.size() + == static_cast(channel_info.width) + * channel_info.height * (m_header.depth / 8)); + // We simply copy over the row into destination + uint64_t row_index = static_cast(row) * channel_info.width + * (m_header.depth / 8); + std::memcpy(data, channel_info.decompressed_data.data() + row_index, + channel_info.row_length); + } break; + case Compression_ZIP_Predict: { + OIIO_ASSERT(channel_info.decompressed_data.size() + == static_cast(channel_info.width) + * channel_info.height * (m_header.depth / 8)); + // We simply copy over the row into destination + uint64_t row_index = static_cast(row) * channel_info.width + * (m_header.depth / 8); + std::memcpy(data, channel_info.decompressed_data.data() + row_index, + channel_info.row_length); + } break; } return true;