I'm using the createLegendIcon class method, in a PHPMapscript script to generate a high resolution legend (PNG icons with AGG/PNG driver), inserted in a PDF document. The RESOLUTION value in the mapfile is modified from the script to obtain a medium (150 DPI) or high (300 DPI) resolution map. The DEFRESOLUTION is always 75. The map is scaled correctly but the legend icons are always in a poor resolution (normal size) or not well scaled (if oversized). It seems they are generated in a screen resolution.
Here the PHP code for 30 px x 20 px icons :
$factSize = ($myMap -> resolution) / ($myMap -> defresolution);
$myIcon = $myClass -> createLegendIcon(30 * $factSize, 20 * factSize);
Searching in maplegend.c I modified the calls to msDrawLineSymbol and msDrawShadeSymbol in msDrawLegendIcon function : I changed the last parameter from lp->scalefactor to lp-scalefactor * (image_draw->resolutionfactor) and the results are now ok.
I did'nt modify the call to msDrawMarkerSymbol for now.
add test for legend scale-dependant rendering
add support for scale-dependant legend rendering (#4725)