luoxiao123
路人甲
路人甲
  • 注册日期2006-04-06
  • 发帖数6
  • QQ
  • 铜币128枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1713回复:3

[求助]还有就是地图中道路的边界有锯齿的问题arcmap 能解决么?

楼主#
更多 发布于:2006-04-20 09:28
<P>地图中道路的边界有锯齿的问题arcmap 能解决么?</P>
<P>谢谢!</P>
喜欢0 评分0
12312354
路人甲
路人甲
  • 注册日期2005-08-27
  • 发帖数12
  • QQ
  • 铜币67枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于:2006-08-28 20:39
上面的文章不知道能不能帮到你,最近也在做防锯齿的.
举报 回复(0) 喜欢(0)     评分
12312354
路人甲
路人甲
  • 注册日期2005-08-27
  • 发帖数12
  • QQ
  • 铜币67枚
  • 威望0点
  • 贡献值0点
  • 银元0个
2楼#
发布于:2006-08-28 20:37
<DIV class=post>
<DIV class=postsub>
<H2>GDI+ Graphics in ArcMap</H2>
<P><IMG></IMG> </P>
<P>I decided to dig out and retrofit some old code after a recent correspondence drifted into the quality of ArcMap’s onscreen cartography versus something like MapQuest (which is currently using anti-alias effects on their maps). It’s not that ArcMap’s symbology is bad, it’s just missing some of the more modern graphical effects that are present in other graphics programs. For instance, while you can apply alpha transparency to an entire map layer, you cannot apply the same effect to an individual features or elements. Thankfully, the incredible extensibility built right into ArcObjects allows us to extend the framework and include some graphical goodies from GDI+ (via the .Net System.Drawing namespace)</P>
<P>The easiest way to get some GDI+ effects on the map is to just respond to the After* drawing events or use IDisplay.StartDrawing. From there, start firing away at the map’s hDC (wrapped in a Graphics object) using the GDI+ primitives transformed by the appropriate IDisplayTransformation. The Map coclass will combine the resulting effects correctly, so feel free to use the anti-alias smoothing mode or the alpha channel on colors. </P>
<P><IMG></IMG><BR><a href="http://www.spatialdatalogic.com/sdl/Public/Images/Map_GDIPlusWithElements.png" target="_blank" >Three Polygon Elements with Transparency </A></P>
<P>This is good and may be all you need but it’s not enough if you want your effects to be part of the main layer stack or to be permanently stored with the MXD file. For this, you need to create a custom ISymbol that conforms to all of ArcObject’s expected interfaces. At first glance, this seems like a perfect opportunity to use .Net’s mixed mode inheritance, building on the base ArcObjects symbol classes. While it is possible to inherit from a COM class (actually, the RCW of the COM class), you will not get the desired effect when that derived class is handed back to unmanaged code. It works perfectly well when you are calling this class from inside .Net’s managed control, but the interface hierarchy is flattened once it’s passes back through the CCW into COM land (actually, at regasm time not runtime). Again, this will work but if you are trying to override some behavior of an explicitly declared interface (say ISymbol in our case), your version of the interface in your derived class will not be called. It is the underlying base class’s implementation that will get called, which pretty much negates the intent of the override. So, mixed mode COM aggregation only works in the managed environment and since it is ArcMap that is ultimately invoking our class methods, clearly this is not an option for our purposes. </P>
<P>[Update - After some more checking, it does in fact work when overriding the default methods with None on the ClassInterfaceType, so aggregation works and seems to work well. Everything below still applies, just don't use the Inner class, use the base ;) ]</P>

<P>This leaves us with completely writing the symbol class on our own or, more to my liking use good old containment inheritance and delegate many of the incoming calls to an inner symbol class. We really only want to override the drawing of the symbol to the screen, so all we are interested in is the ISymbol Draw, SetupDC and ResetDC methods. Everything else can be directed towards the contained symbol object. SetupDC is just caching the Graphics (via Graphics.FromHdc) and Transformation objects for use during Draw. ResetDC cleans up when done. The real work happens inside Draw, where we need to transform the passed IGeometry into something that can used by the .Net drawing primitives. Likewise, we need to craft the proper Brushes/Pens to use based on the inner symbol object. Both operations can get complicated depending on what level of fidelity we are trying to achieve. First, we need to examine the passed IGeometry and in the case of a polygon, create the representative GraphicsPath for the draw operation. This is just a matter of crawling the geometries (rings, paths etc.) and copying the transformed coordinates (via the stored IDisplayTransformation) into Point[] arrays [1]. </P>
<P>
<P></P>
<br><CODE>      GraphicsPath gp = new GraphicsPath();<BR>      FromPolygon(<BR>            gp, <BR>            (IPolygon)Geometry, <BR>            (IDisplayTransformation)_Transformation);                   <BR>                        <BR> <BR>      //====================<BR>      //stroke and fill path<BR>      using (gp)<BR>      {<BR>            Color c = getNetColor(_Inner.Color);<BR>            Brush b = new SolidBrush(c);<BR>            using (b) <BR>            {<BR>                  _Graphics.FillPath(b, gp);<BR>            }<BR>      }<BR>  </CODE>
<p>
<P>IPersistStream/IPersistVariant and IClone – These interfaces need to be implemented by custom symbols, it’s how ArcMap stores and copies your object to and from dialogs, styles and elements. You will get a NullReference exception if you try to use your class without properly implementing these interfaces. Some items I noticed: 1) Use your class’s ProgID (or explicitly set GUID) in the IPersistVariant.ID property. 2) A curiosity of the COM interop layer can be seen during the IClone.Clone and IPersistVariant.Load method calls. Both Clone and Stream.Read return what looks like a raw IUnknown pointer instead of what I thought would be a valid RCW object. It’s not and its use will wreak havoc on any forthcoming code that uses those objects. It’s a quick fix though, a call like below gets you the correct object.</P>
<P> IClone c = _Inner as IClone;<BR> IClone cloned = c.Clone();<BR> object ccw = Marshal.CreateWrapperOfType(<BR>  cloned, <BR>  typeof(SimpleLineSymbolClass));</P>
<P><BR>Here’s some final results to compare the two methods:<BR><a href="http://www.spatialdatalogic.com/sdl/Public/Images/Map_GDIRegular.png" target="_blank" >With Regular ArcMap Symbols</A><BR><a href="http://www.spatialdatalogic.com/sdl/Public/Images/Map_GDIPlus.png" target="_blank" >With GDI+ Symbols</A> (not the text symbols)<BR><a href="http://www.spatialdatalogic.com/sdl/Public/Images/Map_GDIPlusWithShading.png" target="_blank" >Another shading example</A></P>
<P><BR>So, GDI+ can add some graphical polish to your maps but be careful with these effects, some people actually find it harder to read anti-aliased text. Additionally, because of the smoothing of the pixels around the strokes, the increase in the number of unique pixel values can dramatically increase the image size when saving to a GIF or PNG. </P>
<P><BR>HTH<BR>Listening t  <a href="http://music.msn.com/album/?album=10580351" target="_blank" >Kings of Leon - California Waiting</A></P>
<P>[1] – at first I thought this would be a prohibitively expensive operation but in practice, the interop penalty did not seem as great as I would have expected. YMMV.</P>
<P><FONT size=+0></FONT> </P>
<DIV class=postfoot>posted on Monday, December 13, 2004 3:46 PM by <a href="http://www.spatialdatalogic.com/cs/user/Profile.aspx?UserID=1000" target="_blank" >admin</A> </DIV></DIV></DIV><!--
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
<rdf:Description
rdf:about="http://www.spatialdatalogic.com/cs/blogs/brian_flood/archive/2004/12/13/3.aspx"
dc:identifier="http://www.spatialdatalogic.com/cs/blogs/brian_flood/archive/2004/12/13/3.aspx"
dc:title="GDI+ Graphics in ArcMap"
trackback:ping="http://www.spatialdatalogic.com/cs/blogs/trackback.aspx?PostID=3" />
</rdf:RDF>
-->
<DIV><a href="http://www.spatialdatalogic.com/cs/blogs/brian_flood/comments/3.aspx" target="_blank" >Post a Comment</A> :: </DIV>
<H3>Comments</H3>
<DIV>
<H4><a href="http://www.spatialdatalogic.com/cs/blogs/brian_flood/archive/2004/12/13/3.aspx#129" target="_blank" >#</A> re: GDI+ Graphics in ArcMap </H4>
<DIV class=commentssubhead>Monday, October 03, 2005 4:58 PM by <a href="http://www.spatialdatalogic.com/cs/user/Profile.aspx?UserID=1001" target="_blank" >Jeff</A> </DIV>
<DIV class=commentsbody>This is really cool. I was looking for a way to do something just like this. I am not yet very familiar with ArcGIS and COM, any change you could add a link to some source code? </DIV></DIV>
举报 回复(0) 喜欢(0)     评分
benker
路人甲
路人甲
  • 注册日期2006-06-20
  • 发帖数2
  • QQ
  • 铜币105枚
  • 威望0点
  • 贡献值0点
  • 银元0个
3楼#
发布于:2006-08-16 10:27
<P>呵呵,这个问题目前解决不了的……</P>

<P>现在基本上都是在通过其它矢量图形进行重新处理,如AI、CD等……</P>

<img src="images/post/smile/dvbbs/em08.gif" />
举报 回复(0) 喜欢(0)     评分
游客

返回顶部