Fix Image format RGB565 conversion

This commit is contained in:
BlueCube3310
2025-03-05 17:42:28 +01:00
parent c2202d36c1
commit 638c6a5659
4 changed files with 6 additions and 45 deletions
-22
View File
@@ -172,10 +172,6 @@ static Ref<Image> _dds_load_layer(Ref<FileAccess> p_file, DDSFormat p_dds_format
// Calculate the space these formats will take up after decoding.
switch (p_dds_format) {
case DDS_BGR565:
size = size * 3 / 2;
break;
case DDS_BGR5A1:
case DDS_B2GR3A8:
case DDS_LUMINANCE_ALPHA_4:
@@ -214,24 +210,6 @@ static Ref<Image> _dds_load_layer(Ref<FileAccess> p_file, DDSFormat p_dds_format
wb[dst_ofs + 3] = a ? 255 : 0;
}
} break;
case DDS_BGR565: {
// To RGB8.
int colcount = size / 3;
for (int i = colcount - 1; i >= 0; i--) {
int src_ofs = i * 2;
int dst_ofs = i * 3;
uint8_t b = wb[src_ofs] & 0x1F;
uint8_t g = (wb[src_ofs] >> 5) | ((wb[src_ofs + 1] & 0x7) << 3);
uint8_t r = wb[src_ofs + 1] >> 3;
wb[dst_ofs + 0] = r << 3;
wb[dst_ofs + 1] = g << 2;
wb[dst_ofs + 2] = b << 3;
}
} break;
case DDS_BGRA4: {
// To RGBA4.