//
// png_handle_sRGB from 0xbdfb68 to 0xbdfc50 (232 bytes)
//
// 4 xrefs:
// > png_push_read_chunk @ 0xbcf7b8
// > png_read_info @ 0xbd3674
// > png_read_end @ 0xbd5bfc
// > ??> @ 0xbd480
//
// 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_handle_sRGB(__int64 a1, __int64 a2, unsigned int a3)
{
int v3; // w3
__int64 result; // x0
unsigned __int8 v7; // [xsp+2Fh] [xbp+2Fh] BYREF
v3 = *(_DWORD *)(a1 + 356);
if ( (v3 & 1) == 0 )
png_chunk_error(a1, "missing IHDR");
if ( (v3 & 6) != 0 )
{
png_crc_finish((_DWORD *)a1, a3);
return png_chunk_benign_error(a1, "out of place");
}
else if ( a3 == 1 )
{
png_crc_read(a1, (__int64)&v7, 1u);
result = png_crc_finish((_DWORD *)a1, 0);
if ( !(_DWORD)result )
{
result = *(unsigned __int16 *)(a1 + 1370);
if ( (result & 0x8000) == 0 )
{
if ( (result & 4) != 0 )
{
*(_WORD *)(a1 + 1370) = result | 0x8000;
png_colorspace_sync(a1, a2);
return png_chunk_benign_error(a1, "too many profiles");
}
else
{
png_colorspace_set_sRGB(a1, a1 + 1296, v7);
return png_colorspace_sync(a1, a2);
}
}
}
}
else
{
png_crc_finish((_DWORD *)a1, a3);
return png_chunk_benign_error(a1, "invalid");
}
return result;
}