Resource leak in TransparentBlt function 
Author Message
 Resource leak in TransparentBlt function

Hi All,

        I am using following code segment to draw transparent bitmap.
Resource leak will occur in Win98 and in Win Me due to the function
TransparentBlt(); . Is there any problem in my code or in TransparentBlt()
Function. How can I avoid resource leak caused by this function ? .

Can anyone help me

Thank You

Deepak

DrawTransparentBitmap(CDC &dc, CRect DrawRect, UINT BmpId, COLORREF
TransparentColor)

{

CBitmap *pBitmap = new CBitmap();

pBitmap->LoadBitmap(BmpId);

BITMAP Bmp;

pBitmap->GetBitmap(&Bmp);

CDC MemDc;

MemDc.CreateCompatibleDC(&dc);

CBitmap *pOldBitmap = (CBitmap *)MemDc.SelectObject(pBitmap);

::TransparentBlt(dc.m_hDC,OutRect.left,OutRect.top,OutRect.Width(),OutRect.H
eight(),MemDc.m_hDC, 0, 0,Bmp.bmWidth,Bmp.bmHeight,RGB(192,192,192));

MemDc.SelectObject(pOldBitmap);

MemDc.DeleteDC();

pBitmap->DeleteObject();

delete pBitmap;

pBitmap = NULL;

Quote:
}



Wed, 25 Aug 2004 20:52:46 GMT  
 Resource leak in TransparentBlt function
It might be a known problem with TransparentBlt. See MSDN Article Q300555, "FIX: TransparentBlt
Leaks Memory in Msimg32.dll", although it claims that the problem, "...was corrected in [ME]", it
may be the same thing.

Jeff...
--
Please post all follow-ups to the newsgroup only.

Quote:

> Hi All,

>         I am using following code segment to draw transparent bitmap.
> Resource leak will occur in Win98 and in Win Me due to the function
> TransparentBlt(); . Is there any problem in my code or in TransparentBlt()
> Function. How can I avoid resource leak caused by this function ? .

> Can anyone help me

> Thank You

> Deepak

> DrawTransparentBitmap(CDC &dc, CRect DrawRect, UINT BmpId, COLORREF
> TransparentColor)

> {

> CBitmap *pBitmap = new CBitmap();

> pBitmap->LoadBitmap(BmpId);

> BITMAP Bmp;

> pBitmap->GetBitmap(&Bmp);

> CDC MemDc;

> MemDc.CreateCompatibleDC(&dc);

> CBitmap *pOldBitmap = (CBitmap *)MemDc.SelectObject(pBitmap);

> ::TransparentBlt(dc.m_hDC,OutRect.left,OutRect.top,OutRect.Width(),OutRect.H
> eight(),MemDc.m_hDC, 0, 0,Bmp.bmWidth,Bmp.bmHeight,RGB(192,192,192));

> MemDc.SelectObject(pOldBitmap);

> MemDc.DeleteDC();

> pBitmap->DeleteObject();

> delete pBitmap;

> pBitmap = NULL;

> }



Thu, 26 Aug 2004 03:16:24 GMT  
 Resource leak in TransparentBlt function
from what i've heard, transparentblit is very incompatible (doesn't work on
win95??).

You're probably better off using a combination of two different modes with
the basic bitblt function (i've forgotten which ones they are)... a quick
search should bring something up.

hth,
The Other Jeff :D



Thu, 26 Aug 2004 10:24:22 GMT  
 Resource leak in TransparentBlt function
Now in 98 resouce leak problem is solved , but the bitmaps are not
transparent .


Quote:
> It might be a known problem with TransparentBlt. See MSDN Article Q300555,

"FIX: TransparentBlt
Quote:
> Leaks Memory in Msimg32.dll", although it claims that the problem, "...was

corrected in [ME]", it
Quote:
> may be the same thing.

> Jeff...
> --
> Please post all follow-ups to the newsgroup only.




Quote:
> > Hi All,

> >         I am using following code segment to draw transparent bitmap.
> > Resource leak will occur in Win98 and in Win Me due to the function
> > TransparentBlt(); . Is there any problem in my code or in
TransparentBlt()
> > Function. How can I avoid resource leak caused by this function ? .

> > Can anyone help me

> > Thank You

> > Deepak

> > DrawTransparentBitmap(CDC &dc, CRect DrawRect, UINT BmpId, COLORREF
> > TransparentColor)

> > {

> > CBitmap *pBitmap = new CBitmap();

> > pBitmap->LoadBitmap(BmpId);

> > BITMAP Bmp;

> > pBitmap->GetBitmap(&Bmp);

> > CDC MemDc;

> > MemDc.CreateCompatibleDC(&dc);

> > CBitmap *pOldBitmap = (CBitmap *)MemDc.SelectObject(pBitmap);

::TransparentBlt(dc.m_hDC,OutRect.left,OutRect.top,OutRect.Width(),OutRect.H

- Show quoted text -

Quote:
> > eight(),MemDc.m_hDC, 0, 0,Bmp.bmWidth,Bmp.bmHeight,RGB(192,192,192));

> > MemDc.SelectObject(pOldBitmap);

> > MemDc.DeleteDC();

> > pBitmap->DeleteObject();

> > delete pBitmap;

> > pBitmap = NULL;

> > }



Fri, 27 Aug 2004 18:20:45 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Resource leak in TransparentBlt.

2. Is this a resource leak

3. Help with resource leak

4. Finding resource leaks in VC6.0

5. Tools for locating resource leaks

6. bitmap handles and resource leak question

7. Resource Leak?

8. An Unknown Resources leak ?!?

9. Strange resource leaking problem

10. to catch a resource leak

11. Device Context in a Thread causes Resource Leak

12. Diff between m_hDC and m_hAttribDC? Resource leak

 

 
Powered by phpBB® Forum Software