BitBlt & EnhMetaFile
Posted on 2003-03-26
and again I got a question concernin Windows GUI.
I want to do the following:
I have an array of color values for a normal bitmap.
I want this bitmap to be copied into an enhanced meta file.
So first, I create a DC compatible to the Screen,
Then I create the DIB-section with CreateDIBSection,
fill in the color values,
and select it into the dc.
Next I create an emf-dc with CreateEnhMetaFile.
Now I do BitBlt the dc to the emf-dc.
Then I unselect the bmitmap from the dc,
deleteobject the bitmap and deletedc the dc.
later, i deletedc the emf-dc (and deleteenhmetafile
the emf-handles i got with closeenhmetafile).
Now my problem: This leads to a memory leak.
Whenever I use this algorithm, i loose about the size
of the bitmap of memory.
if i leave bitblt away, the leak disappeares
(but also the content of the image).
since i'm dealing with big images, there're 200mb ram
thrown out the window whenever it comes to action.
I need help to remove the memory leak.
Can somebody help me with hints what i'm missing
or small example code (c++ or delphi)?
the stuff's direct api, so please no components/mfc.
thanks a lot,