Comment 140 for bug 179988

Revision history for this message
Adrian Johnson (ajohnson-redneon) wrote : Re: [Bug 179988] Re: no printing from Windows

Rygle wrote:
> Adrian: Thanks for the cairo libs. I've uncommented
> cairo_surface_set_fallback_resolution (surface, x_dpi, y_dpi) and this
> improves things a fair bit. The dpi can be set there manually (eg: 1200)
> to improve things even more, but I think really this needs to be dynamic
> to allow the printer to set the resolution.

 From the patch:
> + x_dpi = GetDeviceCaps (hdc, LOGPIXELSX);
> + y_dpi = GetDeviceCaps (hdc, LOGPIXELSY);
> +
> + x_off = GetDeviceCaps (hdc, PHYSICALOFFSETX);
> + y_off = GetDeviceCaps (hdc, PHYSICALOFFSETY);
[...]
> + surface = cairo_win32_printing_surface_create (hdc);
> + //cairo_surface_set_fallback_resolution (surface, x_dpi, y_dpi);

The x_dpi and y_dpi are the printer resolution.

But the problem with doing this is for example you are using a 1200dpi
laser with 8"x11" paper and cairo does a full page fallback due a radial
gradient over the whole page the memory required is:

1200*8*1200*11*4 = 483MB

It is actually double that as cairo needs to create another image to
blend the transparent parts into white. Even if your PC has enough
memory for this you printer will probably choke on it.

And most of this is wasted on laser printers where due to the half
toning a 1200dpi laser could probably only do 240dpi for color images.

So we need find a better way to set the fallback resolution like make it
a user selectable option. For now I would not hard code it any higher
than 300dpi. But if you are seeing obvious differences between 300dpi
and 1200dpi there may be a bug somewhere that is causing a lower value
to be used.