Loading color scheme

[C++ Code Sample] How to determine printer resoultion?

Printing in Windows API is quite easy - one can paint all the graphics on the Printer DC the same way as on the screen DC. But the difference between the screen and printer is that Printer may have a different dots/inch ratio. The dots/inch ratio is called DPI and is usually higher on printers than on Computer screens.

How do we know the DPI resolution for the printer, given it's devicecontext?

	int dpiX, dpiY;	

	HDC hdc = GetPrinterDC(hwnd);

	dpiX = GetDeviceCaps(hdc, LOGPIXELSX); // the x-DPI for printer
	dpiY = GetDeviceCaps(hdc, LOGPIXELSY); // the y-DPI for printer

For screens, the dpiX and dpiY will be usually set to 72, while printers may use 300 or 600 DPI

Further reading may be found here:GetDeviceCaps (MSDN)

 

GetDeviceCaps

Get all interesting articles to your inbox
Please wait