The D3D9 image loader must preserve source dimensions and exact source pixels. The generic D3DX Texture.FromStream / FromFile overload rounded Scriver’s 400 x 90 native sheet to 512 x 128 and Bosspider’s 203 x 135 sheet to 256 x 256. Its default filtering also introduced colors absent from the content palette. Sprite crops then used the original coordinates on a resized sheet, and exact palette lookup mapped unknown interpolated colors to transparent index zero. This made Scriver, Bosspider and Petitpider nearly invisible.
DX9Engine.CreateImageTextureFromStream reads the original image information, requests exactly that width/height, one mip level, unfiltered ARGB pixels and no mip filtering. File loading delegates to the same path. Assets and palettes are unchanged. Frame textures may still use their existing power-of-two padding; the source image is never resized to fill that padding.
Dx9SpriteImageTests reproduces the failure with the embedded Scriver and Bosspider assets. Before the fix, all four initial cases failed: both dimensions differed and opaque crop pixels became transparent. The completed suite compares every source pixel for embedded and file loading, and every palette index in six representative crops, including walking/climbing Petitpider frames. Tests create a real D3D9 device and read source/cropped textures back without loading a ROM, an audio device or a level.
The native render suite also exercises the SDL-backed Direct3D 11 and OpenGL drivers, including palette lookup, mirroring, transparency, render targets and resource lifetime. These tests validate rendering operations; they do not establish original-game scene/animation parity.
dotnet test XSharp.Render.Tests/XSharp.Render.Tests.csproj
dotnet build XSharpDemo/XSharpDemo.csproj