<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p
{mso-style-priority:99;
margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman",serif;}
span.EmailStyle18
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:#1F497D;}
span.EmailStyle19
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:#1F497D;}
span.EmailStyle20
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">I am attaching an example.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">I tried to get it to just one note without success, it appears to matter where these appear on the page horizontally not just vertically, so I just experimented
with a very few notes until I got a size that worked. The issue is in the third measure on the bottom staff and the second note. That note should be bisected by the line, instead it is significantly too high, ambiguous with being between lines (i.e. it is
an F, it looks like a G if you read music).<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">The JPG shows how I see it. Viewed in Adobe it is correct.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">The relevant code that produces it is this:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";color:#1F497D">Poppler::Page* tmpPage = ((PDFDocument*)ourParent)->document->page(mPage - 1);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";color:#1F497D">QSizeF thisPageSize = tmpPage->pageSizeF(); // in 72's of inch<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";color:#1F497D">double scaleX = (double)mWidth / ((double)thisPageSize.width() / (double)72.0);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";color:#1F497D">double scaleY = (double)mHeight / ((double)thisPageSize.height() / (double)72.0);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";color:#1F497D">double desiredScale = std::min(scaleX, scaleY);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";color:#1F497D">ourParent->document->setRenderHint(Poppler::Document::Antialiasing);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";color:#1F497D">ourParent->document->setRenderHint(Poppler::Document::TextAntialiasing);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";color:#1F497D">ourParent->document->setRenderHint(Poppler::Document::ThinLineSolid);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";color:#1F497D">QImage* theImage = new QImage(tmpPage->renderToImage(desiredScale,desiredScale));<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">The variables are:
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">mPage = 1<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">thisPageSize = (612,792)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">mWidth=1200<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">mHeight=1857<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">desiredScale = 141.176 (as printed if I add qDebug()).<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">The extraneous "double" casts were just making sure I was keeping double precision, as the printed value of 141.176 (when I write to qDebug()) on the scale looks
a bit odd, as the math works out to 141.1764706...<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">I did a lot of photoshop exploring and I am pretty sure this is a matter of a single pixel. That was a surprise, that you can even see that (this is normally
on a 1920x1080 screen). So this may actually just be a rounding issue (if "issue" is not too strong of a word).
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">I'll dig a bit in the code, but am handicapped by not knowing a thing about the actual PDF structure, so the code is a bit mysterious in terms of where the object
placement may be, at least at present. But I'll give it a shot, meanwhile will truncate to an integral scale factor and see if I see the issue as we use the software.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Again, I realize it's a pretty picky detail, especially as I am seeing it may be literally one pixel difference, so thanks in advance to anyone willing to follow
all this and make suggestions.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Linwood Ferguson<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> poppler [mailto:poppler-bounces@lists.freedesktop.org]
<b>On Behalf Of </b>pqt@LEFerguson.com<br>
<b>Sent:</b> Tuesday, March 21, 2017 11:23 PM<br>
<b>To:</b> William Bader <williambader@hotmail.com>; poppler@lists.freedesktop.org<br>
<b>Subject:</b> Re: [poppler] Scaling factor and placement accuracy<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">I'm working with music that is copyrighted (that I own) that I digitize and the produce the PDF's from the digitization (for my own use). Let me see if I can
find one that's public domain and reproduce the issue there. Or maybe better yet just dummy something up manually. I don't want to get the copyright swat team interested.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">I am rendering to an image in a QT5 program via the QT5 wrappers for poppler, then displaying the image on the monitor. My initial runs were with PDF's containing
just one big image, but when I put the music into notation software (Musescore in this example) the resulting PDF, I believe, has individual objects for each element on the screen. Though that's more educated guess than sure fact.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">I did some brief experimenting forcing the scale to integers, and did not see the problem, but it was way too brief; by complete coincidence my piano's player
system was being replaced today so I did not have opportunity to experiment very much.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Re bugs: I was not suggesting it is a bug, more just asking for any insight into whether there are limitations on scaling accuracy.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">I'll try to dummy up a PDF manually to reproduce the issue tomorrow. Thanks for responding.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Linwood<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> William Bader [</span><a href="mailto:williambader@hotmail.com"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">mailto:williambader@hotmail.com</span></a><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">]
<br>
<b>Sent:</b> Tuesday, March 21, 2017 11:11 PM<br>
<b>To:</b> </span><a href="mailto:pqt@LEFerguson.com"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">pqt@LEFerguson.com</span></a><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">;
</span><a href="mailto:poppler@lists.freedesktop.org"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">poppler@lists.freedesktop.org</span></a><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><br>
<b>Subject:</b> Re: [poppler] Scaling factor and placement accuracy<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div id="divtagdefaultwrapper">
<p><span style="font-family:"Calibri",sans-serif;color:black">Could you post a PDF example? Poppler issues can be reported at </span><a href="https://bugs.freedesktop.org/enter_bug.cgi?product=poppler" id="LPlnk359916"><span style="font-family:"Calibri",sans-serif">https://bugs.freedesktop.org/enter_bug.cgi?product=poppler</span></a><span style="font-family:"Calibri",sans-serif;color:black"><o:p></o:p></span></p>
<p><span style="font-family:"Calibri",sans-serif;color:black">Are you rendering to the screen or to a file? pdftocairo and pdftoppm both have antialiasing options.<o:p></o:p></span></p>
<p><span style="font-family:"Calibri",sans-serif;color:black">I think that Splash filling is done in poppler/SplashOutputDev.cc and Gfx.cc. The type of fill depends on the commands in the PDF, so probably the first step would be looking at the PDF to see how
it draws the notes. Hopefully one of the poppler developers will have more detailed advice.<o:p></o:p></span></p>
<p><span style="font-family:"Calibri",sans-serif;color:black">Regards, William<o:p></o:p></span></p>
<div>
<div>
<div class="MsoNormal" align="center" style="text-align:center"><span style="font-family:"Calibri",sans-serif;color:black">
<hr size="2" width="98%" align="center">
</span></div>
<div id="x_divRplyFwdMsg">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:black">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:black"> poppler <</span><a href="mailto:poppler-bounces@lists.freedesktop.org"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">poppler-bounces@lists.freedesktop.org</span></a><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:black">>
on behalf of </span><a href="mailto:pqt@LEFerguson.com"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">pqt@LEFerguson.com</span></a><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:black"> <</span><a href="mailto:pqt@LEFerguson.com"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">pqt@LEFerguson.com</span></a><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:black">><br>
<b>Sent:</b> Tuesday, March 21, 2017 2:06 PM<br>
<b>To:</b> </span><a href="mailto:poppler@lists.freedesktop.org"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">poppler@lists.freedesktop.org</span></a><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:black"><br>
<b>Subject:</b> [poppler] Scaling factor and placement accuracy</span><span style="font-family:"Calibri",sans-serif;color:black">
<o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri",sans-serif;color:black"> <o:p></o:p></span></p>
</div>
</div>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:10.0pt;font-family:"Calibri",sans-serif;color:black">OK, this is going to seem awfully picky, so with apologies in advance.<br>
<br>
Can anyone offer some guidance as to whether scale factors, when doing a renderToImage, have an internal effect on accuracy?<br>
<br>
I have been chasing a very minor, but very annoying issue, and I think it comes down to what scale factor is in use. The application I wrote dynamically scales the PDF page image to the nearest size it can to completely fill the page while maintaining aspect
ratio.<br>
<br>
This displays music. The music is sometimes (specifically when coming from notation software) individual items, where each note is a PDF element. In those cases, sometimes, not often but sometimes the notes are misplaced a bit. I am attaching an example.
I actually have seen much worse, but I had this handy with all the debugging.<br>
<br>
On the bottom example it is a screen shot of Adobe's reader. The top is Poppler's rendering at scale 150. The middle is the problem example, it is scaled 98.1818 (I have rescaled the screen shots to be the same size in photoshop to produce the collage for
viewing).<br>
<br>
Notice the ever so slightly higher position of the F's (second from top note) on the middle staff. I've tried to indicate the center with the hand-drawn arrow.<br>
<br>
That may seem like a slight issue, but these are occurring quite a lot, and they fool the eye when sight reading causing you to think it is the wrong note.<br>
<br>
Originally I thought it was the notational software, but Adobe's viewer, and even Poppler at some scaling factors places them perfectly. At others they are shifted.<br>
<br>
I plan to now do some experimentation with different roundings, and try to see a pattern, but for people who know the code ... is there any guidance? Like use integers, or some other limitations on scale factors? Or perhaps are there any compilation options
that impact the accuracy of the calculations? <br>
<br>
This is the latest committed version of poppler pulled and built from source today with the default rendering engine (Splash) and with hints Antialiasing, TextAntialiasing, and ThinLineSolid turned on . The problems have been on the Raspberry pi, so it's 32
bit os, but both the top and middle example in the attachment are on the Pi, so it is not always an issue.<br>
<br>
Anyway, again apologies if this seems like an awfully trivial item, but was just hoping someone may have encountered similar issues and had any advice.<br>
<br>
Linwood Ferguson<o:p></o:p></span></p>
</div>
</div>
</div>
</div>
</div>
</body>
</html>