Skip to content

Commit

Permalink
wip(vtfpp): fix bluescreen alpha encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
craftablescience committed May 29, 2024
1 parent fbb38c4 commit 965d1eb
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions src/vtfpp/ImageConversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,21 +216,45 @@ namespace {
}
break;
case RGB888:
case RGB888_BLUESCREEN:
for (int i = 0; i < imageData.size(); i += 4) {
newData.push_back(imageData[i]);
newData.push_back(imageData[i + 1]);
newData.push_back(imageData[i + 2]);
}
break;
case RGB888_BLUESCREEN:
for (int i = 0; i < imageData.size(); i += 4) {
if (static_cast<uint8_t>(imageData[i + 3]) == 0) {
newData.push_back(std::byte{0});
newData.push_back(std::byte{0});
newData.push_back(std::byte{0xff});
} else {
newData.push_back(imageData[i]);
newData.push_back(imageData[i + 1]);
newData.push_back(imageData[i + 2]);
}
}
break;
case BGR888:
case BGR888_BLUESCREEN:
for (int i = 0; i < imageData.size(); i += 4) {
newData.push_back(imageData[i + 2]);
newData.push_back(imageData[i + 1]);
newData.push_back(imageData[i + 0]);
}
break;
case BGR888_BLUESCREEN:
for (int i = 0; i < imageData.size(); i += 4) {
if (static_cast<uint8_t>(imageData[i + 3]) == 0) {
newData.push_back(std::byte{0xff});
newData.push_back(std::byte{0});
newData.push_back(std::byte{0});
} else {
newData.push_back(imageData[i + 2]);
newData.push_back(imageData[i + 1]);
newData.push_back(imageData[i + 0]);
}
}
break;
case RGB565:
for (int i = 0; i < imageData.size(); i += 4) {
uint16_t rgb565 =
Expand Down

0 comments on commit 965d1eb

Please sign in to comment.