From 278c442959ecb407f5c6fbae6d30f0dd6b841707 Mon Sep 17 00:00:00 2001 From: st0rmbtw Date: Mon, 27 Jan 2025 09:38:37 +0300 Subject: [PATCH] Calculate proper offsets for the source data in ConvertImageBufferFormatWorker --- sources/Core/ImageFlags.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/sources/Core/ImageFlags.cpp b/sources/Core/ImageFlags.cpp index ce57b2259d..c15e70c822 100644 --- a/sources/Core/ImageFlags.cpp +++ b/sources/Core/ImageFlags.cpp @@ -557,20 +557,24 @@ static void ConvertImageBufferFormatWorker( SetVariantMinMax(srcImageView.dataType, colorValue.b, true); SetVariantMinMax(srcImageView.dataType, colorValue.a, false); - for_subrange(i, begin, end) + for_subrange(k, begin, end) { + const size_t rowStride = GetImageRowStride(srcImageView, extent); + const size_t y = k / extent.width; + const size_t i = k % extent.width; + /* Apply source and destination stride when passing an edge */ - if (i > 0 && i % extent.width == 0) + if (k > 0 && i == 0) { - srcBuffer.int8 += srcRowPadding; + // srcBuffer.int8 += srcRowPadding; dstBuffer.int8 += dstRowPadding; } /* Read RGBA variant from source buffer */ - ReadRGBAFormattedVariant(srcImageView.format, srcImageView.dataType, srcBuffer, i, colorValue); + ReadRGBAFormattedVariant(srcImageView.format, srcImageView.dataType, srcBuffer.int8 + y * rowStride, i, colorValue); /* Write RGBA variant to destination buffer */ - WriteRGBAFormattedVariant(dstImageView.format, dstImageView.dataType, dstBuffer, i, colorValue); + WriteRGBAFormattedVariant(dstImageView.format, dstImageView.dataType, dstBuffer, k, colorValue); } } }