Last FWH version. Memory leak.

User avatar
carlos vargas
Posts: 1421
Joined: Tue Oct 11, 2005 5:01 pm
Location: Nicaragua

Re: Last FWH version. Memory leak.

Post by carlos vargas »

Antonio

entonces la linea

Code: Select all

    lpBits = ( LPBYTE ) hb_xgrab( iXsize * iYsize * 2 );
    if( lpBits )
    {
    }
    hb_xfree( lpBits );
 
estaria de mas, ya que no se estaria usando ese dato (tamano en byte del bitmap), no deberia eliminarse?
y el codigo contenido en el bloque, sacarlo fuera.
salu2
carlos vargas
Salu2
Carlos Vargas
Desde Managua, Nicaragua (CA)
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Last FWH version. Memory leak.

Post by Antonio Linares »

Carlos,

Si, de hecho en las modificaciones nuestras ya lo hemos eliminado :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Marco Turco
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London
Contact:

Re: Last FWH version. Memory leak.

Post by Marco Turco »

Hi Antonio,
I didn't understand if the problem has been solved and if affirmative which is the new code to use. Thanks.
Best Regards,

Marco Turco
SOFTWARE XP LLP
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Last FWH version. Memory leak.

Post by Antonio Linares »

Marco,

Solved. There was a bug in the code and we have shown how to fix it :-)

It will be included in FWH 13.02

This code has to be replaced in FWH\source\function\fwbmp.c

Code: Select all

void TransBmp( HBITMAP hBitmap, int iXsize, int iYsize,
               COLORREF rgbTransparent, HDC hDC,
               int iXOffset, int iYOffset, int iWidth, int iHeight )
{
  HDC mDC, nDC;
  HBITMAP hMask, hBmOld1, hBmOld2;

  mDC = CreateCompatibleDC( hDC );
  
  if( mDC )
  {
    hBmOld1 = ( HBITMAP ) SelectObject( mDC, hBitmap );

    hMask = CreateBitmap( iXsize, iYsize, 1, 1, NULL );
    
    if( hMask )
    {
       nDC = CreateCompatibleDC( hDC );
        
       if( nDC )
       {
          hBmOld2 = ( HBITMAP ) SelectObject( nDC, hMask );
          SetBkColor( mDC, rgbTransparent );

          BitBlt( nDC, 0, 0, iXsize, iYsize, mDC, 0, 0, SRCCOPY );

          SetStretchBltMode( hDC, COLORONCOLOR );

          StretchBlt( hDC, iXOffset, iYOffset, iWidth, iHeight,
                      mDC, 0, 0, iXsize, iYsize,
                      SRCINVERT );

          StretchBlt( hDC, iXOffset, iYOffset, iWidth, iHeight,
                      nDC, 0, 0, iXsize, iYsize,
                      SRCAND );

          StretchBlt( hDC, iXOffset, iYOffset, iWidth, iHeight,
                      mDC, 0, 0, iXsize, iYsize,
                      SRCINVERT );

          SelectObject( nDC, hBmOld2 );
          DeleteDC( nDC );
        }
        DeleteObject( hMask );
    }
    SelectObject( mDC, hBmOld1 );
    DeleteDC( mDC );
  }
}
 
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply