//
// png_write_tRNS from 0x874f08 to 0x8750ca (450 bytes)
//
// 1 xrefs:
// > png_write_info @ 0x871b52
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:03:01 +0000
//
int __fastcall png_write_tRNS(int a1, int a2, int a3, int a4, int a5)
{
int v7; // r1
_BYTE v11[2]; // [sp+8h] [bp-10h] BYREF
_BYTE v12[2]; // [sp+Ah] [bp-Eh] BYREF
_BYTE v13[4]; // [sp+Ch] [bp-Ch] BYREF
_BYTE v14[4]; // [sp+10h] [bp-8h] BYREF
_BYTE v15[4]; // [sp+14h] [bp-4h] BYREF
if ( a5 == 3 )
{
if ( a4 > 0 && a4 <= *(unsigned __int16 *)(a1 + 520) )
{
*(_DWORD *)(a1 + 900) = 34;
png_save_uint_32(v14, a4);
png_save_uint_32(v15, 1951551059);
png_write_data(a1);
*(_DWORD *)(a1 + 476) = 1951551059;
png_reset_crc(a1);
png_calculate_crc((_DWORD *)a1, (int)v15, 4);
*(_DWORD *)(a1 + 900) = 66;
png_write_chunk_data((_DWORD *)a1, a2, a4);
return png_write_chunk_end(a1);
}
else
{
return png_app_warning(a1, "Invalid number of transparent colors specified");
}
}
else if ( a5 )
{
if ( a5 == 2 )
{
png_save_uint_16(v11, *(_WORD *)(a3 + 2));
png_save_uint_16(v12, *(_WORD *)(a3 + 4));
png_save_uint_16(v13, *(_WORD *)(a3 + 6));
if ( *(_BYTE *)(a1 + 536) == 8 && v11[0] | v12[0] | v13[0] )
{
return png_app_warning(a1, "Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8");
}
else
{
*(_DWORD *)(a1 + 900) = 34;
png_save_uint_32(v14, 6);
png_save_uint_32(v15, 1951551059);
png_write_data(a1);
*(_DWORD *)(a1 + 476) = 1951551059;
png_reset_crc(a1);
png_calculate_crc((_DWORD *)a1, (int)v15, 4);
*(_DWORD *)(a1 + 900) = 66;
png_write_chunk_data((_DWORD *)a1, (int)v11, 6);
return png_write_chunk_end(a1);
}
}
else
{
return png_app_warning(a1, "Can't write tRNS with an alpha channel");
}
}
else
{
v7 = *(unsigned __int16 *)(a3 + 8);
if ( v7 < 1 << *(_BYTE *)(a1 + 536) )
{
png_save_uint_16(v11, v7);
*(_DWORD *)(a1 + 900) = 34;
png_save_uint_32(v14, 2);
png_save_uint_32(v15, 1951551059);
png_write_data(a1);
*(_DWORD *)(a1 + 476) = 1951551059;
png_reset_crc(a1);
png_calculate_crc((_DWORD *)a1, (int)v15, 4);
*(_DWORD *)(a1 + 900) = 66;
png_write_chunk_data((_DWORD *)a1, (int)v11, 2);
return png_write_chunk_end(a1);
}
else
{
return png_app_warning(a1, "Ignoring attempt to write tRNS chunk out-of-range for bit_depth");
}
}
}