/* * test_plane_dump.c — 宿主解码正确性校验:把 meow_font 解码出的打包像素面 dump 成二进制, * 供 Python 参考解码(zlib IDAT + 反滤波)逐字节比对,验证流式解码与参考解码完全一致。 * 需以 -DMEOW_FONT_ENABLE_DEBUG 编译 meow_font.c 暴露 meow_font_debug_plane。 */ #include "meow_font.h" #include #include /* 宿主调试钩子:定义于 meow_font.c(MEOW_FONT_ENABLE_DEBUG 下才编译);此测试自带声明。 */ extern const unsigned char *meow_font_debug_plane(int slot, unsigned *w, unsigned *h, unsigned *depth, size_t *rowbytes); int main(int argc, char **argv) { if (argc < 4) { fprintf(stderr, "usage: %s \n", argv[0]); return 2; } int r = meow_font_load(argv[1], argv[2]); if (r != 0) { fprintf(stderr, "load failed %d\n", r); return 1; } unsigned w, h, depth; size_t rb; const unsigned char *p = meow_font_debug_plane(0, &w, &h, &depth, &rb); if (!p) { fprintf(stderr, "no plane\n"); return 1; } size_t total = (size_t)rb * h; FILE *f = fopen(argv[3], "wb"); if (!f) { return 1; } /* 先写出几何头(小端),再写平面字节 */ unsigned hdr[5] = { w, h, depth, (unsigned)rb, (unsigned)total }; fwrite(hdr, sizeof(unsigned), 5, f); fwrite(p, 1, total, f); fclose(f); printf("dumped w=%u h=%u depth=%u rowbytes=%zu bytes=%zu\n", w, h, depth, rb, total); meow_font_unload(); return 0; }