SetPixel (), BitBlt () problems with windows 9x

The Amyuni PDF Converter is our Printer Driver that enables you to convert any documents to PDF format. If you have any questions about installing and using the Amyuni PDF Converter please post them here.
Post Reply
tiagog
Posts: 3
Joined: Tue May 06 2003
Location: Brazil

SetPixel (), BitBlt () problems with windows 9x

Post by tiagog »

Hi,

I'm using a developer PDF converter license to create PDFs from DWG files from a visual c++ application, using the COM interface (CDINTF.DLL). What I'm doing is initializing the driver (DriverInit ()) and getting a DC from it (CreateDC ()). Then I create a memory only DC and render my drawing on it (a simplified version of my code is shown below). Only after the rendering I start my printing job and copy the contents of my memory DC to the printers DC, using StretchDIBits () (first I have to convert my DDB to a DIB).
Well, this works fine for printing files in Windows 95 through XP, with any printer that I tested so far. The only problem I'm having is with generating PDFs on Windows 95/98 machines: I get a huge PDF file with nothing in it, just a blank page, and acrobat just reports something like "insuficient data to display" (my messages are in portuguese). The PDF generations works just fine in Windows NT/2000/XP.
I made a simple test in witch I just get a DC to the PDF printer and do some SetPixel () calls, and the same problem happens, again just in windows 9x. I tested this with PDF Converter versions 1.39 and 2.07, same problem. Below is my code just to illustrate:

Code: Select all

/*------------------------------------------------------------------------------*/

ICDIntfPtr ptrPdf;
HRESULT hr = ptrPdf.CreateInstance (__uuidof (CDIntf));
if (FAILED(hr))
{
     return;
}
	
ptrPdf->DriverInit ("PDF Compatible Printer Driver") ;

HDC dc = (HDC)ptrPdf->CreateDC (); //ptrPdf was initialized before
CDC dcPrint;
CRect rect;

CalculatePrintArea (rect); 

dcPrint.CreateCompatibleDC (CDC::FromHandle (dc));
CBitmap bitmap;
bitmap.CreateCompatibleBitmap (CDC::FromHandle (dcPrint), rect.Width (), rect.Height  ());	
dcPrint.SelectObject (&bitmap);
SetBkColor (dcPrint, RGB (255,255,255));		
	    
RenderDWGFile (myfile, dcPrint.m_hDC); 
	
StartDoc(dc, &di);    
StartPage(dc);                     
	
CPalette pal;
HANDLE hDIB = DDBToDIB ((HBITMAP)bitmap.GetSafeHandle (), BI_RGB, (HPALETTE)pal.GetSafeHandle ());
		
if (GetDeviceCaps (dc, RASTERCAPS) & RC_BITBLT)
{
        SetBkColor (dc, RGB(255,255,255));
        SetTextColor (dc, RGB(0,0,0));

	LPBITMAPINFOHEADER lpbi;
	lpbi = (LPBITMAPINFOHEADER)hDIB;
	int nColors = lpbi->biClrUsed ? lpbi->biClrUsed : 1 <<     lpbi->biBitCount;
	BITMAPINFO &bmInfo = *(LPBITMAPINFO)hDIB;
	LPVOID lpDIBBits;
	if( bmInfo.bmiHeader.biBitCount > 8 )
		lpDIBBits = (LPVOID)((LPDWORD)(bmInfo.bmiColors +   bmInfo.bmiHeader.biClrUsed) + ((bmInfo.bmiHeader.biCompression == BI_BITFIELDS) ? 3 : 0));
	else
		lpDIBBits = (LPVOID)(bmInfo.bmiColors + nColors);
				
	
    StretchDIBits(dc,				// hDC
			0,							// DestX
			0,							// DestY
			rect.Width (),			// nDestWidth
			rect.Height (),						// nDestHeight
			0,				// SrcX
			0,	// SrcY
			rect.Width (),			// wSrcWidth
			rect.Height (),						// wSrcHeight
			lpDIBBits,					// lpBits
			&bmInfo,					// lpBitsInfo
			DIB_RGB_COLORS,				// wUsage
			SRCCOPY);					// dwROP

	
    GlobalFree(hDIB);
	
    EndPage (dc);
    EndDoc(dc);          
}             


/*------------------------------------------------------------------------------*/ 	
 
Is this a bug with PDF Converter? Any suggestions / feedback appreciated,

Thanks,

Tiago Gehring
tiagog@weg.com.br
Post Reply