[Qgis-developer] Unit tests failing - a heartfelt plea

Radim Blazek radim.blazek at gmail.com
Mon Jun 18 04:19:54 PDT 2012


On Sun, Jun 17, 2012 at 8:31 AM, Marco Hugentobler
<marco.hugentobler at sourcepole.ch> wrote:
> Looks like the problem is that, in QgsRenderChecker::runTest, myImage may
> have different DPI depending on the system (in your case, myImage seems to
> have 85/86 and myExpectedImage 96). Could you test if it works if you set
> the DPI of myImage programmatically to 96:

If output image DPI is also set to 96, then it works correctly.

I was curious how Qt gets DPI, it calculates it on X11:
    int widthMM = DisplayWidthMM(X11->display, s);
    screen->dpiX = (DisplayWidth(X11->display, s) * 254 + widthMM * 5)
/ (widthMM * 10);
In my case, if I change display resolution, both DisplayWidth and
DisplayWidthMM are changing, keeping the same DPI, which makes little
sense, I think.

In any case, the test myImage dpi depends on platform. Setting myImage
dpi to myExpectedImage dpi in all raster tests should be sufficient,
right?

> Like that, rasterScaleFactor
>  should be 1.0 on all systems.

The formula
    rasterScaleFactor = ( thePaintDevice->logicalDpiX() +
              thePaintDevice->logicalDpiY() ) / 2.0 / sceneDpi;
ignores that dpiX and dpiY may be different, could it be a problem?

> rasterScaleFactor is there because in the print composer, units are mm and
> so in this case, the raster images have more pixels than output units.
> But for drawing to QImage, rasterScaleFactor is always 1.

Thanks for explanation. Can we be sure, that rasterScaleFactor is
always 1.0 when it should be? Is it true, that if output format is
raster, then rasterScaleFactor should be 1.0? It would be maybe better
to test if output device is QImage or QPicture and force
rasterScaleFactor to 1.0, in that case?

Radim


More information about the Qgis-developer mailing list