Dear guys,
I want to print a screenshot using external printer.
I connected the printer by USB port. I try to print but the print quality is bad.
In the code I use the generic “PCL Laser” .
I tried with the right printer name but the quality is not better.
Could you tell me if this is normal or I 'm wrong anything?
I use the following code lines:
DEVMODE dm;
pBGR bufImage;
memset(&dm, 0, sizeof(DEVMODE));
wcscpy(dm.dmDeviceName,L"PCL Laser");
dm.dmSize = sizeof(DEVMODE);
dm.dmColor = DMCOLOR_MONOCHROME;
dm.dmPaperSize = DMPAPER_A4;
dm.dmPrintQuality = DMRES_DRAFT;
dm.dmFields = DM_PAPERSIZE | DM_PRINTQUALITY | DM_COLOR;
DEVMODE *lpc = &dm;
HDC hdcPrinter = NULL;
hdcPrinter = CreateDC(L"pcl.dll",L"PCL Laser", L"LPT1:", lpc);
// This sets up information for the spooler on document information
DOCINFO lDocInfo = {0};
lDocInfo.cbSize = sizeof(DOCINFO);
lDocInfo.fwType = 0;
lDocInfo.lpszDatatype =0;
lDocInfo.lpszOutput = NULL;
// Start the document - tells windows there is a document coming
StartDoc(hdcPrinter, &lDocInfo);
// Indicates you are starting a new page
StartPage(hdcPrinter);
HBITMAP hbitmapAT;
BITMAPINFO bi;
int nx = 800;
int ny = 400;
bi.bmiHeader.biSize = sizeof(bi.bmiHeader);
bi.bmiHeader.biWidth = nx;
bi.bmiHeader.biHeight = - ny;
bi.bmiHeader.biPlanes = 1;
bi.bmiHeader.biBitCount = 1; //32
bi.bmiHeader.biCompression = BI_RGB;
bi.bmiHeader.biSizeImage = nx * 3 * ny; //4
bi.bmiHeader.biClrUsed = 0;
bi.bmiHeader.biClrImportant = 0;
hwndAudiometriaTonale = FinestraTonale.WinHandle;
hdcAudiometriaTonale = GetDC(hwndAudiometriaTonale);
hbitmapAT = CreateDIBSection(NULL,&bi,DIB_RGB_COLORS,(VOID **) &bufImage,NULL,NULL);
SelectObject(hdcPrinter,hbitmapAT);
BitBlt(hdcPrinter,0,0,800,ny,hdcAudiometriaTonale ,0,0,SRCCOPY);
ReleaseDC(hwndAudiometriaTonale, hdcAudiometriaTonale);
EndPage(hdcPrinter);
EndDoc(hdcPrinter);
Best regards
Matteo