Skip to content

Commit

Permalink
remove image interpretation for bmps
Browse files Browse the repository at this point in the history
  • Loading branch information
DubbleClick committed Sep 27, 2024
1 parent 3f2f127 commit db037f8
Showing 1 changed file with 1 addition and 27 deletions.
28 changes: 1 addition & 27 deletions modules/TextureFunction.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -382,33 +382,7 @@ export namespace TextureFunction {
else {
hr = DirectX::LoadFromWICMemory(entry.data.data(), entry.data.size(), DirectX::WIC_FLAGS_NONE, nullptr, image);
if (image.GetMetadata().format == DXGI_FORMAT_B8G8R8X8_UNORM) {
if (entry.ext == ".bmp") {
DirectX::ScratchImage convertedImage;
hr = Convert(image.GetImages(), image.GetImageCount(), image.GetMetadata(), DXGI_FORMAT_B8G8R8A8_UNORM, DirectX::TEX_FILTER_DEFAULT, DirectX::TEX_THRESHOLD_DEFAULT, convertedImage);
if (FAILED(hr)) {
Warning("ConvertToBGRA (%#lX%s): FAILED\n", entry.crc_hash, entry.ext.c_str());
return {};
}

for (size_t y = 0; y < convertedImage.GetMetadata().height; ++y) {
uint8_t* row = convertedImage.GetImage(0, 0, 0)->pixels + y * convertedImage.GetImage(0, 0, 0)->rowPitch;
for (size_t x = 0; x < convertedImage.GetMetadata().width; ++x) {
const auto blue = row[x * 4 + 0];
const auto green = row[x * 4 + 1];
const auto red = row[x * 4 + 2];

if (red == 0 && green == 0 && blue == 0) {
row[x * 4 + 3] = 0x00; // force transparency
} else {
row[x * 4 + 3] = 0xFF;
}
}
}
image = std::move(convertedImage);
}
else {
image.OverrideFormat(DXGI_FORMAT_B8G8R8A8_UNORM);
}
image.OverrideFormat(DXGI_FORMAT_B8G8R8A8_UNORM);
}
}
entry.data.clear();
Expand Down

0 comments on commit db037f8

Please sign in to comment.