Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » Draw, Display, Images, Bitmaps, Icons » DrawWin32.cpp: PrintDraw::InitPrinter()
Re: DrawWin32.cpp: PrintDraw::InitPrinter() [message #19287 is a reply to message #19253] Mon, 24 November 2008 12:41 Go to previous messageGo to previous message
Tom1
Messages: 1212
Registered: March 2007
Senior Contributor
I'm testing this on Windows XP. Luckily the Epson Stylus Photo 1290 driver has a preview option in XP and it does not even require the printer to exist to be able to install the driver and use its preview option.

There are two separate problems:

1) Only about 60% of width and about 60% of height of the printable area is covered by the printout.

2) The DrawImage(rect,image) produces a broken image probably due to the resolution mismatch (360x360 versus 600x600). It does not get correctly re-scaled from 600 dpi to 360 dpi in the GDI or the printer driver.

Please see the attached files broken.png and fixed.png.

Current code:
::SetMapMode(handle, MM_ANISOTROPIC);
::SetViewportExtEx(handle, inchPixels.cx, inchPixels.cy, NULL);
::SetViewportOrgEx(handle, 0, 0, NULL);
::SetWindowExtEx(handle, 600, 600 , NULL);
::SetWindowOrgEx(handle, 0, 0, NULL);

Result with current code:
index.php?t=getfile&id=1493&private=0
My slightly enhanced solution looks like this:
	
::SetMapMode(handle, MM_ANISOTROPIC);
int dpi=min(inchPixels.cx,inchPixels.cy);
::SetWindowExtEx(handle, dpi*pagePixels.cx/inchPixels.cx, dpi*pagePixels.cy/inchPixels.cy, NULL);
::SetWindowOrgEx(handle, 0, 0, NULL);
::SetViewportExtEx(handle, pagePixels.cx, pagePixels.cy, NULL);
::SetViewportOrgEx(handle, 0, 0, NULL);
pagePixels.cx=dpi*pagePixels.cx/inchPixels.cx; 
pagePixels.cy=dpi*pagePixels.cy/inchPixels.cy; 
inchPixels.cx=dpi;
inchPixels.cy=dpi;

The result after the above changes:
index.php?t=getfile&id=1494&private=0

With the above change, it works with the standard DrawImage.

Just an opinion, but I think the best printing quality can be obtained using the printer's hardware resolution (and optionally dropping it with integer dividers if it is excessively high). For correct page size and scaling I always use Draw::GetPagePixels() and Draw::GetPixelsPerInch() to get the map scale right on both screen and printer.

(This is irrelevant for the current issue at hand, but since it popped up: The SetDIBitsToDevice() uses hardware resolution and does not respect these Viewport/Window mappings except maybe for the starting point. StretchDIBits(), however, does work with the mappings and is also pretty economic way to put low resolution images to high resolution printers, as it does not necessarily pre-rescale the image to the printer resolution before sending it to the printer.)

// Tom
  • Attachment: broken.png
    (Size: 104.54KB, Downloaded 1018 times)
  • Attachment: fixed.png
    (Size: 92.33KB, Downloaded 983 times)
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: how to use non integer coordinates (like OpenGL) with Draw?
Next Topic: Extensions to Draw...Ops
Goto Forum:
  


Current Time: Sun Apr 28 07:25:26 CEST 2024

Total time taken to generate the page: 0.02695 seconds