//
// png_image_begin_read_from_file from 0x657810 to 0x657892 (130 bytes)
//
// 0 xrefs:
//
// 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
//
int __fastcall png_image_begin_read_from_file(_DWORD *a1, char *filename)
{
const char *v2; // r1
FILE *v4; // r5
int *v5; // r0
char *v6; // r1
if ( !a1 )
return 0;
if ( a1[1] != 1 )
{
v2 = "png_image_begin_read_from_file: incorrect PNG_IMAGE_VERSION";
return png_image_error((int)a1, (int)v2);
}
if ( !filename )
{
v2 = "png_image_begin_read_from_file: invalid argument";
return png_image_error((int)a1, (int)v2);
}
v4 = fopen(filename, "rb");
if ( v4 )
{
if ( sub_657580(a1) )
{
*(_DWORD *)(*(_DWORD *)*a1 + 288) = v4;
*(_BYTE *)(*a1 + 20) |= 2u;
return png_safe_execute((int)a1, sub_655964, (int)a1);
}
else
{
fclose(v4);
return 0;
}
}
else
{
v5 = (int *)_errno();
v6 = strerror(*v5);
return png_image_error((int)a1, (int)v6);
}
}