Antonio, i found, that in this function pDip should released with
- Code: Select all Expand view
hb_xfree( ( char * ) pDib );
on 3 positions. I write 1000 BMPs and then the computer-Memory are full in my case. I searched for the reason and found this.
- Code: Select all Expand view
BOOL DibWrite( LPSTR szFileName, HGLOBAL hDIB )
{
long lSize;
char * pDib;
int hBmp;
pDib = DibToStr( hDIB, &lSize );
#ifndef UNICODE
if( ( hBmp = _lcreat( szFileName, 0 ) ) != HFILE_ERROR )
{
_hwrite( hBmp, ( const char * ) pDib, lSize );
_lclose( hBmp );
GlobalUnlock( hDIB );
hb_xfree( ( char * ) pDib );
return TRUE;
}
#else
if( ( hBmp = hb_fsCreate( ( unsigned char * ) szFileName, 0 ) ) != ( int ) INVALID_HANDLE_VALUE )
{
hb_fsWriteLarge( hBmp, ( unsigned char * ) pDib, lSize );
hb_fsClose( hBmp );
GlobalUnlock( hDIB );
hb_xfree( ( char * ) pDib );
return TRUE;
}
#endif
else
{
GlobalUnlock( hDIB );
hb_xfree( ( char * ) pDib );
return FALSE;
}
}