Page 4 of 4

Re: Last FWH version. Memory leak.

Posted: Fri Feb 15, 2013 9:05 pm
by carlos vargas
Antonio

entonces la linea

Code: Select all | Expand


    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

Re: Last FWH version. Memory leak.

Posted: Fri Feb 15, 2013 9:31 pm
by Antonio Linares
Carlos,

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

Re: Last FWH version. Memory leak.

Posted: Wed Feb 20, 2013 10:22 am
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.

Re: Last FWH version. Memory leak.

Posted: Wed Feb 20, 2013 11:54 am
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 | Expand

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 );
  }
}