BmpHeader.ReadDims reads texture dims from the pre-converted BMP header (VM- thread-safe, no pixel decode) — the data source for GetTextureSize. `Age.Cli gfx <SCENE>` runs a scene and dumps set-texture/get-texture-size/draw-texture in order with resolved file + computed geometry, mirroring the `audio` diagnostic. Confirms 0x208 now yields real dims (800x600/800x800/800x227) and sane UI geometry; surfaces the first-load anchor edge (unseeded state, Phase B). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
34 lines
1.0 KiB
C#
34 lines
1.0 KiB
C#
using System.IO;
|
|
using Age.Engine.Sys4;
|
|
using Xunit;
|
|
|
|
public class BmpHeaderTests
|
|
{
|
|
[Fact]
|
|
public void ReadDimsReadsWidthAndHeightFromBmpHeader()
|
|
{
|
|
// Minimal 54-byte BMP header (BITMAPFILEHEADER 14 + BITMAPINFOHEADER 40); width=4, height=3.
|
|
var b = new byte[54];
|
|
b[0] = (byte)'B'; b[1] = (byte)'M';
|
|
System.BitConverter.GetBytes(40).CopyTo(b, 14); // header size
|
|
System.BitConverter.GetBytes(4).CopyTo(b, 18); // width
|
|
System.BitConverter.GetBytes(3).CopyTo(b, 22); // height
|
|
var tmp = Path.Combine(Path.GetTempPath(), "agehdr_test.bmp");
|
|
File.WriteAllBytes(tmp, b);
|
|
try
|
|
{
|
|
var (w, h) = BmpHeader.ReadDims(tmp);
|
|
Assert.Equal(4, w);
|
|
Assert.Equal(3, h);
|
|
}
|
|
finally { File.Delete(tmp); }
|
|
}
|
|
|
|
[Fact]
|
|
public void ReadDimsReturnsZeroForMissingFile()
|
|
{
|
|
var (w, h) = BmpHeader.ReadDims(Path.Combine(Path.GetTempPath(), "does_not_exist_agehdr.bmp"));
|
|
Assert.Equal((0, 0), (w, h));
|
|
}
|
|
}
|