Hi Radim
In any case, the test myImage dpi depends on platform. Setting myImage
dpi to myExpectedImage dpi in all raster tests should be sufficient,
right?
Yes, I think so. QImage is supposed to be independent of the graphics
system (if the dpi is the same).
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?
Right, there is a rounding error detction, but I see the rasterScaleFactor
should be set to 1.0 and it is not done (only the scaling of raster layer is
avoided):
qgsmaprenderer.cpp:
if ( ml->type() == QgsMapLayer::RasterLayer&& qAbs( rasterScaleFactor - 1.0 )>
0.000001 )
{
scaleRaster = true;
}
Detecting the paint devince does not work because it is also possible to
render QGraphicsScene to any paint device (e.g. in composer, the scene
is rendered to QImage if save to image is clicked).
The formula
rasterScaleFactor = ( thePaintDevice->logicalDpiX() +
thePaintDevice->logicalDpiY() ) / 2.0 / sceneDpi;
ignores that dpiX and dpiY may be different, could it be a problem?
They are averaged, but maybe it would be better to take just X?
Regards,
Marco
Am 18.06.2012 13:19, schrieb Radim Blazek:
On Sun, Jun 17, 2012 at 8:31 AM, Marco Hugentobler
<[email protected]> 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
--
Dr. Marco Hugentobler
Sourcepole - Linux& Open Source Solutions
Weberstrasse 5, CH-8004 Zürich, Switzerland
[email protected] http://www.sourcepole.ch
Technical Advisor QGIS Project Steering Committee
_______________________________________________
Qgis-developer mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/qgis-developer