Add Support for D3DFMT_X8R8G8B8 (#214)

This would "fix" the exported xml from having "22" in the embedded texture's format block.
In before this 22 prevents the xml file from importing into blender via Sollumz, caused the common error "KeyError:22" when some people editing weird-making mods.
This commit is contained in:
gg781 2023-08-23 11:26:48 +08:00 committed by GitHub
parent 023cc1eb47
commit 595bb9a375
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 0 deletions

View File

@ -659,6 +659,7 @@ namespace CodeWalker.GameFiles
public enum TextureFormat : uint
{
D3DFMT_A8R8G8B8 = 21,
D3DFMT_X8R8G8B8 = 22,
D3DFMT_A1R5G5B5 = 25,
D3DFMT_A8 = 28,
D3DFMT_A8B8G8R8 = 32,

View File

@ -185,6 +185,10 @@ namespace CodeWalker.Utils
px = imgdata;
swaprb = false;
break;
case DXGI_FORMAT.DXGI_FORMAT_B8G8R8X8_UNORM: // TextureFormat.D3DFMT_X8R8G8B8
px = imgdata;
swaprb = false;
break;
default:
break; //shouldn't get here...
}
@ -491,6 +495,7 @@ namespace CodeWalker.Utils
case DXGI_FORMAT.DXGI_FORMAT_R8G8B8A8_UNORM: format = TextureFormat.D3DFMT_A8B8G8R8; break;
case DXGI_FORMAT.DXGI_FORMAT_R8_UNORM: format = TextureFormat.D3DFMT_L8; break;
case DXGI_FORMAT.DXGI_FORMAT_B8G8R8A8_UNORM: format = TextureFormat.D3DFMT_A8R8G8B8; break;
case DXGI_FORMAT.DXGI_FORMAT_B8G8R8X8_UNORM: format = TextureFormat.D3DFMT_X8R8G8B8; break;
}
return format;
}
@ -514,6 +519,7 @@ namespace CodeWalker.Utils
case TextureFormat.D3DFMT_A8B8G8R8: format = DXGI_FORMAT.DXGI_FORMAT_R8G8B8A8_UNORM; break;
case TextureFormat.D3DFMT_L8: format = DXGI_FORMAT.DXGI_FORMAT_R8_UNORM; break;
case TextureFormat.D3DFMT_A8R8G8B8: format = DXGI_FORMAT.DXGI_FORMAT_B8G8R8A8_UNORM; break;
case TextureFormat.D3DFMT_X8R8G8B8: format = DXGI_FORMAT.DXGI_FORMAT_B8G8R8X8_UNORM; break;
}
return format;
}

View File

@ -30,6 +30,7 @@ namespace CodeWalker.GameFiles
case TextureFormat.D3DFMT_A8B8G8R8: format = Format.R8G8B8A8_UNorm; break;
case TextureFormat.D3DFMT_L8: format = Format.R8_UNorm; break;
case TextureFormat.D3DFMT_A8R8G8B8: format = Format.B8G8R8A8_UNorm; break;
case TextureFormat.D3DFMT_X8R8G8B8: format = Format.B8G8R8X8_UNorm; break;
}
return format;
}
@ -52,6 +53,7 @@ namespace CodeWalker.GameFiles
case TextureFormat.D3DFMT_A8B8G8R8: return 32;// R8G8B8A8_UNorm
case TextureFormat.D3DFMT_L8: return 8;// R8_UNorm
case TextureFormat.D3DFMT_A8R8G8B8: return 32;// B8G8R8A8_UNorm
case TextureFormat.D3DFMT_X8R8G8B8: return 32;// B8G8R8X8_UNorm
default: return 0;
}