feat(a2b): BmpHeader.ReadDims + gfx diagnostic (headless geometry oracle)
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>
This commit is contained in:
25
engine/Age.Engine/Sys4/BmpHeader.cs
Normal file
25
engine/Age.Engine/Sys4/BmpHeader.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
namespace Age.Engine.Sys4;
|
||||
|
||||
/// <summary>
|
||||
/// Reads pixel dimensions from a BMP file header (BITMAPINFOHEADER: width at byte 18, height at byte 22,
|
||||
/// both little-endian int32; height may be negative for top-down bitmaps). Used to give the VM the
|
||||
/// texture size that opcode 0x208 (get-texture-size) needs, without decoding pixels. Our textures are
|
||||
/// pre-converted BMPs (tools/convert_agf.py).
|
||||
/// </summary>
|
||||
public static class BmpHeader
|
||||
{
|
||||
public static (int Width, int Height) ReadDims(string? path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path) || !File.Exists(path)) return (0, 0);
|
||||
try
|
||||
{
|
||||
var b = new byte[26];
|
||||
using var fs = File.OpenRead(path);
|
||||
if (fs.Read(b, 0, 26) < 26 || b[0] != (byte)'B' || b[1] != (byte)'M') return (0, 0);
|
||||
int w = System.BitConverter.ToInt32(b, 18);
|
||||
int h = System.BitConverter.ToInt32(b, 22);
|
||||
return (System.Math.Abs(w), System.Math.Abs(h));
|
||||
}
|
||||
catch { return (0, 0); }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user