//
// png_set_background_fixed from 0xbd7828 to 0xbd78d4 (172 bytes)
//
// 6 xrefs:
// > sub_BD1BEC @ 0xbd2384
// > sub_BD1BEC @ 0xbd27d0
// > sub_BD1BEC @ 0xbd2fd0
// > png_read_row @ 0xbd3e34
// > png_set_background @ 0xbd7918
// > ??> @ 0x31968
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
__int64 __fastcall png_set_background_fixed(__int64 result, __int64 a2, int a3, int a4, int a5)
{
__int64 v5; // x5
int v6; // w6
int v7; // w7
v5 = result;
if ( result )
{
v6 = *(_DWORD *)(result + 360);
if ( (v6 & 0x40) != 0 )
{
return png_app_error(result, "invalid after png_start_read_image or png_read_update_info");
}
else
{
*(_DWORD *)(result + 360) = v6 | 0x4000;
if ( a2 )
{
if ( a3 )
{
v7 = *(_DWORD *)(result + 364);
*(_DWORD *)(result + 360) = v6 & 0xFFFF9FFF | 0x4000;
*(_DWORD *)(result + 364) = v7 & 0xFF7BFF7F | 0x40080;
*(_QWORD *)(result + 704) = *(_QWORD *)a2;
*(_WORD *)(result + 712) = *(_WORD *)(a2 + 8);
*(_DWORD *)(result + 700) = a5;
*(_BYTE *)(result + 698) = a3;
if ( a4 )
{
result = v7 & 0xFF7BFE7F | 0x40180;
*(_DWORD *)(v5 + 364) = result;
}
else
{
result = v7 & 0xFF7BFE7F | 0x40080;
*(_DWORD *)(v5 + 364) = result;
}
}
else
{
return png_warning(result, "Application must supply a known background gamma");
}
}
}
}
return result;
}