Skip to content

Commit c9bce7e

Browse files
vtfpp: revert erroneous change when compressing images with non-multiple of 4 dimension(s)
1 parent 32a3e6d commit c9bce7e

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/vtfpp/ImageConversion.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,12 +344,22 @@ namespace {
344344
}
345345
}
346346

347+
std::vector<std::byte> imageDataReplacement;
348+
/*
349+
const auto populateImageDataReplacement = [&imageData, &imageDataReplacement] {
350+
if (imageDataReplacement.empty()) {
351+
imageDataReplacement = {imageData.begin(), imageData.end()};
352+
}
353+
imageData = imageDataReplacement;
354+
};
355+
*/
356+
347357
uint16_t unpaddedWidth = width, unpaddedHeight = height;
348358
if ((width % 4 != 0 || height % 4 != 0) && ImageFormatDetails::compressed(oldFormat) != ImageFormatDetails::compressed(newFormat)) {
349359
uint16_t paddingWidth = (4 - (width % 4)) % 4, paddingHeight = (4 - (height % 4)) % 4;
350360
if (!ImageFormatDetails::compressed(oldFormat)) {
351-
auto paddedImageData = ImageConversion::padImageData(imageData, oldFormat, width, paddingWidth, height, paddingHeight);
352-
imageData = std::move(paddedImageData);
361+
imageDataReplacement = ImageConversion::padImageData(imageData, oldFormat, width, paddingWidth, height, paddingHeight);
362+
imageData = imageDataReplacement;
353363
}
354364
width += paddingWidth;
355365
height += paddingHeight;

0 commit comments

Comments
 (0)