Kieran France Kieran France is a programmer for IDRSolutions in charge of there internal test suite. In his spare time he enjoys tinkering with gadgets and code.

Screen rendering may not always be perfect

1 min read

Recently I have come to realize that Screen rendering may not always be perfect. Our tests have begun to show changes in their baseline even if run under identical conditions with identical code with no other obvious cause for the changes.

I should explain the basics of how the tests function. We use the Fest library to mimic user interaction with our viewer examples. Whilst Fest is doing this we take screenshots of the component that should be showing some behavior and compare this to a baseline of images that are known to show the correct output. This comparison is done by comparing the pixel colors between the generated output and the baseline.

A little while ago I moved my tests to a new test machine and upon setting up them up I found a slight problem. The tests are failing but the output appears correct when compared to our baseline. The reason the tests are failing is because it is detecting some pixels have changed although the difference in the RGB values can be anything as little as 1 on a single channel to up to 12 (and very rarely higher than this) on multiple channels. The most irritating thing about this is I can run the same code through the tests multiple times and get different sets of results.

In order to find what was wrong I activated some code that will alter the pixel color of any pixel that was of a different color such as Cyan or magenta as these are known not to appear within the output and are very easy to pick out. After running through the tests several times I found that although the output changed it was consistently appearing in the similar positions. The changes always appeared on images found on the PDF page and always at points where two different colors shared an edge. A further problem is that different images show the changes at different times, this means the tests are consistently showing change as when the baseline is updated with the changes to an image, the next time the tests are run these changes are no longer present or only present in certain images.

Unfortunately I have to leave this without a satisfying conclusion as I do not have any hard evidence as to what is causing this issue. Considering the fact that is only appears within images and not text, shapes or any other object within the PDF and that it only happens when the PDF is displayed on screen and not when it is rendered directly to an image I am leaning toward one possibility. It appears that screen rendering may be coming up with slightly different color values when an image is scaled and pixels are merged.

If anyone has ever experienced anything like this or wishes to know more feel free to leave a comment, I would be nice to hear from you.

Are you a Developer working with PDF files?

Our developers guide contains a large number of technical posts to help you understand the PDF file Format.

Find out more about our software for Developers

Convert PDF to HTML5 or SVG Convert PDF to HTML5 or SVG
Convert AcroForms and XFA to HTML5Convert AcroForms and XFA to HTML5
Java PDF SDK for working with PDF files Java PDF SDK for working with PDF files
Kieran France Kieran France is a programmer for IDRSolutions in charge of there internal test suite. In his spare time he enjoys tinkering with gadgets and code.

Leave a Reply

Your email address will not be published. Required fields are marked *

IDRsolutions Ltd 2022. All rights reserved.