/* Read the LIVE official palette: after ThermalSDK Start(), the channel * device object holds the 256-entry palette at dev+0xb00 (4 bytes each, * BGR order). We find the device pointer via MAG_GetOutputBMPdata which * returns the grayscale buffer at dev+0xaf0 - the palette is 0x10 before it. */ #define _WIN32_WINNT 0x0601 #include #include #include #include typedef void (CALLBACK *INewIRFrame)(const unsigned char *, int, int, int); typedef bool (CALLBACK *fn_Start_t)(void); typedef void (CALLBACK *fn_Stop_t)(void); typedef void (CALLBACK *fn_SetNewIRFrameDelegate_t)(INewIRFrame); typedef int (CALLBACK *MAG_GetOutputBMPdata_t)(int, int *, unsigned char **); typedef int (CALLBACK *MAG_GetOutputBMPdataRGB24_t)(int, unsigned char *, int, int); typedef int (CALLBACK *MAG_GetOutputColorBardata_t)(int, unsigned char *, int); static volatile int g_frames; static void CALLBACK onIR(const unsigned char *buf, int w, int h, int ch) { (void)buf; (void)w; (void)h; (void)ch; g_frames++; } int main(void) { SetDllDirectoryA("C:\\Project\\MAG160C\\IR_Camera_SDK-1.0.1\\windows\\windows\\app"); HMODULE t = LoadLibraryA("ThermalSDK.dll"); HMODULE c = LoadLibraryA("CoreSDKLib.dll"); if (!t || !c) return 1; fn_Start_t T_Start = (fn_Start_t)GetProcAddress(t, "Start"); fn_Stop_t T_Stop = (fn_Stop_t)GetProcAddress(t, "Stop"); fn_SetNewIRFrameDelegate_t T_Set = (fn_SetNewIRFrameDelegate_t)GetProcAddress(t, "SetNewIRFrameDelegate"); MAG_GetOutputBMPdata_t G_Gray = (MAG_GetOutputBMPdata_t)GetProcAddress(c, "MAG_GetOutputBMPdata"); MAG_GetOutputBMPdataRGB24_t G_RGB = (MAG_GetOutputBMPdataRGB24_t)GetProcAddress(c, "MAG_GetOutputBMPdataRGB24"); MAG_GetOutputColorBardata_t G_Bar = (MAG_GetOutputColorBardata_t)GetProcAddress(c, "MAG_GetOutputColorBardata"); T_Set(onIR); BOOL ok = T_Start(); printf("Start=%d\n", ok); fflush(stdout); Sleep(3000); for (int chan = 0; chan < 5; ++chan) { int w = 0; unsigned char *graybuf = NULL; int rc = G_Gray(chan, &w, &graybuf); printf("chan %d gray rc=%d buf=%p\n", chan, rc, (void*)graybuf); if (rc && graybuf) { /* palette at graybuf - 0x10 (dev+0xaf0 - 0x10 = dev+0xae0?) * Actually palette is dev+0xb00 = graybuf + 0x10 */ unsigned char *pal = graybuf + 0x10; FILE *f = fopen("official_palette_live.bin", "wb"); if (f) { fwrite(pal, 1, 256 * 4, f); fclose(f); } printf("saved official_palette_live.bin (first entries):\n"); for (int i = 0; i < 12; ++i) { printf(" %2d: %3d %3d %3d %3d\n", i, pal[i*4], pal[i*4+1], pal[i*4+2], pal[i*4+3]); } /* also dump a few RGB24 render pixels to correlate */ unsigned char rgb[160*120*3]; int rc2 = G_RGB(chan, rgb, 160*120*3, 1); printf("RGB24 rc=%d\n", rc2); break; } } T_Stop(); printf("done\n"); return 0; }