[Interest] Black background with QPrinter

Konrad Rosenbaum konrad at silmor.de
Sat Mar 18 13:47:03 CET 2017


On Friday 17 March 2017 18:03:38 Giuseppe D'Angelo wrote:
> On Fri, Mar 17, 2017 at 5:42 PM, Joshua Grauman <jnfo-c at grauman.com> 
wrote:
>> Thanks for the other info as well. I'm curious about your comment about
>> printers with white ink. Presummably they could print on a black piece of
>> paper. Would Qt support that? Or would the only way to support that be
>> via the setFullPage option?
>
> If you paint white text, it will be painted in white by a white-ink
> printer. The parts you don't paint upon will not be touched. So if you
> feed black paper into such printer, you'll get white-on-black text.

[...I'll pile on a bit, feel free to ignore me...]

Or in the case that made me realize how printing colors works a few years 
ago: I got a picture of a white snowflake on a dark blue sweatshirt. ;-)

You need to realize that the picture created by almost any printing 
framework (including QPrinter) actually has a transparent background - the 
parts you paint on get some kind of color, everything else remains as "naked 
print medium" - unprinted paper, untouched cloth, whatever...

There are two extremes when it comes to what colors are available on a 
printer: full color printers that include white ink (e.g. professional 
poster printers and some expensive textile printers) and monochrome printers 
(e.g. label printers that work with thermo paper). In the former case you 
can explicitly create any color on the medium no matter what color the 
medium is; in the latter case any color no matter how subtle will translate 
to black (usually except white, but there are buggy drivers). In both cases 
it is important to not put any elements on the spaces you do not want to be 
painted on. 

In the middle there are the normal office printers that assume that the 
medium is white and then put a white background behind your file and 
translate the colors to a combination of white paper and colored ink.

What setFullPage influences is simply where you are allowed to paint, i.e. 
where you are allowed to try to add explicit color. 

What happens in the background is that the printer driver knows (or thinks 
it knows) what parts of the medium can be safely reached by the printing 
head. It then tells QPrinter what the margins are. You have to explicitly 
tell QPrinter to ignore those margins, which implies you know your risk that 
the driver and/or hardware will ignore part of the picture.

<rant>
On Windows it gets worse: the printing sub-system assumes that all 
programmers are idiots who are unable to handle multiple different printers 
and tells you the worst margins of any printer configured in the system - 
which can lead to a lot of fun if you have fundamentally different printers 
attached; e.g. an office printer driver that believes in margins of 1cm and 
a label printer that prints on 3cm high labels, but has no margins - you'll 
end up with completely useless settings for the label printer if you do not 
enforce the use of setFullPage.
</rant>



	Konrad
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20170318/f9fbee82/attachment.sig>


More information about the Interest mailing list