//
// cocos2d::CCImage::_saveImageToJPG from 0x18007bb90 to 0x18007be2a (666 bytes)
//
// 6 xrefs:
// > ??> @ 0x18013c0c4
// > ??> @ 0x18013c0f8
// > ??> @ 0x18013c110
// > ??> @ 0x18013c124
// > ??> @ 0x1801438a8
// > ??> @ 0x1801b4da0
//
// 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
//
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 m_nWidth; // [rsp+60h] [rbp-A0h]
unsigned int m_nHeight; // [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);
m_nWidth = this->m_nWidth;
m_nHeight = this->m_nHeight;
v22 = 3;
v23 = 2;
jpeg62_81(v19);
LOBYTE(v6) = 1;
jpeg62_86(v19, v6);
v7 = this->m_nWidth;
v8 = 3 * v7;
if ( !this->m_bHasAlpha )
{
for ( i = v24; v24 < m_nHeight; i = v24 )
{
v18[0] = &this->m_pData[v8 * i];
jpeg62_98(v19, v18, 1);
}
goto LABEL_16;
}
v9 = operator new(3 * v7 * this->m_nHeight);
if ( v9 )
{
v10 = 0;
if ( this->m_nHeight )
{
LOWORD(v11) = this->m_nWidth;
do
{
v12 = 0;
if ( (_WORD)v11 )
{
do
{
v9[3 * v12 + 3 * v10 * (unsigned __int16)v11] = this->m_pData[4 * v12 + 4 * v10 * (unsigned __int16)v11];
v13 = v12 + v10 * this->m_nWidth;
v9[3 * v13 + 1] = this->m_pData[4 * v13 + 1];
v14 = v12 + v10 * this->m_nWidth;
++v12;
v9[3 * v14 + 2] = this->m_pData[4 * v14 + 2];
v11 = this->m_nWidth;
}
while ( v12 < v11 );
}
++v10;
}
while ( v10 < this->m_nHeight );
}
for ( j = v24; v24 < m_nHeight; 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;
}