<HTML><HEAD><TITLE>[mapguide-users] Overriding DPI</TITLE>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<META content="MSHTML 6.00.6000.16525" name=GENERATOR></HEAD>
<BODY dir=ltr>
<DIV>The output looks correct in that if the resulting images are each viewed on a device that has the&nbsp;corresponding DPI resolution, the map scale of 5000 would be correct if physically measured with a ruler.</DIV>
<DIV>&nbsp;</DIV>
<DIV>What exactly do you think is incorrect?&nbsp;The math behind it goes something like this:</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT color=#0000ff size=2>
<P>double</FONT><FONT size=2> metersPerUnit = map-&gt;GetMetersPerUnit();</P></FONT></DIV>
<DIV><FONT size=2>
<P></FONT><FONT color=#0000ff size=2>double</FONT><FONT size=2> metersPerPixel = 0.0254 / dpi;</P>
<P></FONT><FONT color=#0000ff size=2>double</FONT><FONT size=2> mappingWidth =&nbsp;imageWidth</FONT><FONT size=2> * metersPerPixel * scale / metersPerUnit;</P></FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>You can see that the width (and also height) of the visible region will vary inversely with DPI, if everything else is constant.</DIV>
<DIV>&nbsp;</DIV>
<DIV>Traian</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV><FONT size=2>-----Original Message----- <BR><B>From:</B> mapguide-users-bounces@lists.osgeo.org&nbsp;on behalf of&nbsp;simon hope <BR><B>Sent:</B> Thu 9/6/2007 6:59 PM <BR><B>To:</B> mapguide-users@lists.osgeo.org <BR><B>Cc:</B> <BR><B>Subject:</B> [mapguide-users] Overriding DPI<BR><BR></FONT></DIV><BR>
<P><FONT size=2>Hi,<BR><BR>I'm trying a number of methods for exporting images:<BR><BR>1. I used the MgRenderingService class to produce an image (had to use a<BR>nasty hack to get the current extent as map.GetDataExtent(); doesn't seem to<BR>work?), but using this method does not give me any control over the image<BR>dpi.<BR><BR>2. I then sent a request over HTTP directly to the MapAgent CGI - this gives<BR>me the flexibilty to pass parameters over the URL, however when I set<BR>different DPI values, I always get an image set at 72 dpi. Here is a sample<BR>of the request:<BR><BR><A href="http://localhost/mapguide/mapagent/mapagent.fcgi?OPERATION=GETMAPIMAGE&amp;VERSION=1.0.0&amp;SESSION=6669fbe4-0000-1000-8000-0013d3c0f8fe_en_C0A801140AFC0AFB0AFA&amp;MAPNAME=Sheboygan&amp;LOCALE=en&amp;FORMAT=PNG&amp;SETVIEWCENTERX=-87.732492&amp;SETVIEWCENTERY=43.743934&amp;SETVIEWSCALE=5000&amp;SETDISPLAYDPI=96&amp;SETDISPLAYWIDTH=1024&amp;SETDISPLAYHEIGHT=768">http://localhost/mapguide/mapagent/mapagent.fcgi?OPERATION=GETMAPIMAGE&amp;VERSION=1.0.0&amp;SESSION=6669fbe4-0000-1000-8000-0013d3c0f8fe_en_C0A801140AFC0AFB0AFA&amp;MAPNAME=Sheboygan&amp;LOCALE=en&amp;FORMAT=PNG&amp;SETVIEWCENTERX=-87.732492&amp;SETVIEWCENTERY=43.743934&amp;SETVIEWSCALE=5000&amp;SETDISPLAYDPI=96&amp;SETDISPLAYWIDTH=1024&amp;SETDISPLAYHEIGHT=768</A><BR><BR>This URL uses 96 DPI - if i sent the same URL but increased the DPI, this<BR>has the effect of changing the extent of the actual image, despite keeping<BR>the other parameters static.<BR><BR>I read on a post that DPI can be overriden "if the session allows it"? Does<BR>this mean that I have to update the session somewhere?<BR><BR>I have attached three images using different DPI values (96, 300 and 600)<BR>which illustrates the effect.<BR><BR><A href="http://www.nabble.com/file/p12533054/http_request96.png">http://www.nabble.com/file/p12533054/http_request96.png</A> http_request96.png<BR><A href="http://www.nabble.com/file/p12533054/http_request300.png">http://www.nabble.com/file/p12533054/http_request300.png</A> http_request300.png<BR><A href="http://www.nabble.com/file/p12533054/http_request600.png">http://www.nabble.com/file/p12533054/http_request600.png</A> http_request600.png<BR><BR>I have also tried to increase the image width and height as I increase the<BR>dpi - this maintains the extent of the image, but does not alter the dpi.<BR>This method also results in some rather strange labelling&nbsp; - the number of<BR>labels increases per feature.<BR><BR>Cheers<BR><BR>Simon<BR><BR><BR><BR>--<BR>View this message in context: <A href="http://www.nabble.com/Overriding-DPI-tf4395160s16610.html#a12533054">http://www.nabble.com/Overriding-DPI-tf4395160s16610.html#a12533054</A><BR>Sent from the MapGuide Users mailing list archive at Nabble.com.<BR><BR>_______________________________________________<BR>mapguide-users mailing list<BR>mapguide-users@lists.osgeo.org<BR><A href="http://lists.osgeo.org/mailman/listinfo/mapguide-users">http://lists.osgeo.org/mailman/listinfo/mapguide-users</A><BR></FONT></P></BLOCKQUOTE></BODY></HTML>