why StretchBlt allocated two times memory in windows 2003 than xp?

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
This function is called by my virtual print driver to convert bmp to EMF.
<pre>void GetEmfByBytes(BYTE * pBits, int iWidth, int iHeight, WCHAR* szPrinterName, WCHAR* szDestinationFile,DWORD rop=SRCCOPY)
{
BITMAP bm;

HDC hdcMem = CreateCompatibleDC(GetDC(NULL));
HDC hPrinterDC = ::CreateDC(NULL,szPrinterName, NULL, NULL);

BITMAPINFOHEADER bmih;
memset(&bmih, 0, sizeof(BITMAPINFOHEADER));

bmih.biSize = sizeof(BITMAPINFOHEADER);
bmih.biBitCount = 1;
bmih.biCompression = BI_RGB;
bmih.biPlanes = 1;
bmih.biWidth = iWidth;
bmih.biHeight = iHeight;

BITMAPINFO bmi;
memset(&bmi, 0, sizeof(BITMAPINFO));

bmi.bmiHeader = bmih;

HBITMAP hBmp = ::CreateDIBitmap(hPrinterDC,&bmih,CBM_INIT,pBits,&bmi,0);

GetObject(hBmp, sizeof(BITMAP), &bm );
SelectObject(hdcMem, hBmp);
HDC emfdc = CreateEnhMetaFile(hPrinterDC, szDestinationFile, NULL, L"");

if(emfdc!=NULL){
StretchBlt(emfdc,0, 0, bm.bmWidth, -bm.bmHeight, hdcMem, 0, 0, bm.bmWidth, bm.bmHeight, rop);/* From task manager I found the memory of spoolsv.exe ncreased 4M in xp, while 8M in windows 2003.*/
HENHMETAFILE hEMFFile = CloseEnhMetaFile(emfdc);/* 4M memory were released in both xp and windows 2003. So 4M memory were still not released in windows 2003. Memory Leak!*/
DeleteEnhMetaFile(hEMFFile);
}[/code]
<pre>else{
logOut( wstring(L"cant create emf")+szDestinationFile );
}

DeleteDC(hPrinterDC);
DeleteDC(hdcMem);
DeleteObject(hBmp);
}
[/code]

<br/>
<br/>
<br/>
<br/>

View the full article
 
Back
Top