//
// cocos2d::CCImage::_saveImageToJPG from 0x18007eda0 to 0x18007f03a (666 bytes)
//
// 6 xrefs:
// > ??> @ 0x180145440
// > ??> @ 0x180145474
// > ??> @ 0x18014548c
// > ??> @ 0x1801454a0
// > ??> @ 0x18014cf68
// > ??> @ 0x1801bf07c
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// 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 11:22:01 +0000
//
bool __fastcall cocos2d::CCImage::_saveImageToJPG(cocos2d::CCImage *this, const char *a2)
{
FILE *v4; // rax
FILE *v5; // r14
__int64 v6; // rdx
int v7; // eax
int v8; // esi
_BYTE *v9; // rdi
int v10; // r9d
int v11; // ecx
int v12; // r10d
int v13; // ecx
int v14; // ecx
unsigned int j; // eax
unsigned int i; // eax
_QWORD v18[2]; // [rsp+20h] [rbp-E0h] BYREF
_QWORD v19[6]; // [rsp+30h] [rbp-D0h] BYREF
int v20; // [rsp+60h] [rbp-A0h]
unsigned int v21; // [rsp+64h] [rbp-9Ch]
int v22; // [rsp+68h] [rbp-98h]
int v23; // [rsp+6Ch] [rbp-94h]
unsigned int v24; // [rsp+150h] [rbp+50h]
_BYTE v25[176]; // [rsp+230h] [rbp+130h] BYREF
if ( !a2 )
{
LOBYTE(v4) = 0;
return (char)v4;
}
v19[0] = jpeg62_89(v25);
jpeg62_30(v19, 62, 504);
v4 = fopen(a2, "wb");
v5 = v4;
if ( !v4 )
return (char)v4;
jpeg62_90(v19, v4);
v20 = *((unsigned __int16 *)this + 28);
v21 = *((unsigned __int16 *)this + 29);
v22 = 3;
v23 = 2;
jpeg62_81(v19);
LOBYTE(v6) = 1;
jpeg62_86(v19, v6);
v7 = *((unsigned __int16 *)this + 28);
v8 = 3 * v7;
if ( !*((_BYTE *)this + 72) )
{
for ( i = v24; v24 < v21; i = v24 )
{
v18[0] = *((_QWORD *)this + 8) + v8 * i;
jpeg62_98(v19, v18, 1);
}
goto LABEL_16;
}
v9 = (_BYTE *)sub_1800E4C6C(3 * v7 * *((unsigned __int16 *)this + 29));
if ( v9 )
{
v10 = 0;
if ( *((_WORD *)this + 29) )
{
LOWORD(v11) = *((_WORD *)this + 28);
do
{
v12 = 0;
if ( (_WORD)v11 )
{
do
{
v9[3 * v12 + 3 * v10 * (unsigned __int16)v11] = *(_BYTE *)(4 * (v12 + v10 * (unsigned __int16)v11)
+ *((_QWORD *)this + 8));
v13 = v12 + v10 * *((unsigned __int16 *)this + 28);
v9[3 * v13 + 1] = *(_BYTE *)(4 * v13 + *((_QWORD *)this + 8) + 1LL);
v14 = v12 + v10 * *((unsigned __int16 *)this + 28);
++v12;
v9[3 * v14 + 2] = *(_BYTE *)(4 * v14 + *((_QWORD *)this + 8) + 2LL);
v11 = *((unsigned __int16 *)this + 28);
}
while ( v12 < v11 );
}
++v10;
}
while ( v10 < *((unsigned __int16 *)this + 29) );
}
for ( j = v24; v24 < v21; j = v24 )
{
v18[0] = &v9[v8 * j];
jpeg62_98(v19, v18, 1);
}
j_j_free_0(v9);
LABEL_16:
jpeg62_49(v19);
fclose(v5);
jpeg62_43(v19);
LOBYTE(v4) = 1;
return (char)v4;
}
jpeg62_49(v19);
jpeg62_43(v19);
fclose(v5);
LOBYTE(v4) = 0;
return (char)v4;
}