Deleting HBITMAP memory from GDI+ Bitmap

Guys,

I am using the GDI+ libraries to load up images. I have loaded up the image into a Bitmap structure. I then need to get a handle to the HBITMAP so I used GetHBITMAP(). Then I get the DIB on this HBITMAP and then try to free the the HBITMAP .... in the following way:

LPSTR pDIB;
HBITMAP hbmp;

gdiBitmap->GetHBITMAP(NULL, &hbmp);
GetDIBits(*pDC, hbmp, 0, sizey, pDIB + sizeof(BITMAPCOREHEADER), (BITMAPINFO *)pDIB, DIB_RGB_COLORS));
DeleteObject(hbmp);

Now when I look at the memory usage my PF Usage in Windows Task Manager jumps up drastically when I get the HBITMAP and not by much when I GetDIBits(). But when I call DeleteObject on the HBITMAP it does not reduce the PF Usage by the same amount as the GetHBITMAP call increased it by.

Why is this. I can keep doing this or my app will explode soon.

regards,

Gordon.
jeffreygAsked:
Who is Participating?
 
moduloCommented:
Closed, 75 points refunded.

modulo
Community Support Moderator
Experts Exchange
0
 
jeffreygAuthor Commented:
I got it myself. It was nothing to do with deleting the object HBITMAP but deleteing the Bitmap structure afterwards.

regards,

G.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.