Go HOWTO: Replace Picturemarkersymbol with ImageBrush to enhance graphic display performance

Source: Internet
Author: User

Original address: http://support.esrichina-bj.cn/2009/0728/1007.html

Article ID: 37033

Software: ArcGIS API for Microsoft SILVERLIGHT/WPF 9.3.1

Operating System: N/A

Summary:

ArcGIS API for Microsoft SILVERLIGHT/WPF contains a Picturemarkersymbol class that uses a picture icon to render graphic points. Like other symbols in the API, its contents are defined by a control template.

The Picturemarkersymbol control template is defined as follows:


<controltemplate xmlns= "http://schemas.microsoft.com/client/2007"
xmlns:x= "Http://schemas.microsoft.com/winfx/2006/xaml" >
<image source= "{Binding Symbol.source}"
Opacity= "{Binding symbol.opacity}"
Stretch= "Fill"
Width= "{Binding symbol.width}"
height= "{Binding symbol.height}"/>
</ControlTemplate>

When assigned to a Graphic (for example, Graphic.symbol), an image control instance is created. If the same picture marker symbol is assigned to a 500 graphic point, the image is decoded 500 times. As a result, the initial graphic rendering will become relatively slow. Although the symbol is bound to a picture resource and therefore shared in 500 graphics (downloaded only once), the picture decoding is not shared.
To reduce the overhead associated with the image control used by Picturemarkersymbol, use ImageBrush to create a custom control template for the symbol.

The description describes how to use ImageBrush instead of Picturemarkersymol to enhance the display performance of graphic.

Content:

Starting with a container that has the Fill property, which can be set to any type of brush (for example, Rectangle). Use ImageBrush to refer to the target picture (image) so that it can be used to symbolize the graphics. ImageBrush is responsible for decoding the picture, so it can be shared among all the graphic features that will use it. Then, when the custom symbol is assigned to 500 graphic points, 500 of the rectangle instances are created (as defined in the template), but only one image brush is generated. The following is the underlying control template for the symbol:


<controltemplate
Xmlns= "http://schemas.microsoft.com/client/2007"
xmlns:x= "Http://schemas.microsoft.com/winfx/2006/xaml" >
<rectangle fill= "{Binding Symbol.fill}"
Opacity= "{Binding symbol.opacity}"
Width= "{Binding symbol.width}"
height= "{Binding symbol.height}"/>
</ControlTemplate>

Start by using the Markersymbol class contained in the ArcGIS API for Microsoft SILVERLIGHT/WPF, or create a new custom symbol from scratch. In either case, the custom marker symbol class should have a public fill property that can be used to bind to the brush. Here is just an example of how to define a customized control template for the Markersymbol class:


<Grid.Resources>
<imagebrush imagesource= "/images/i_pushpin.png" x:name= "Myimagebrush"/>
<esrisymbols:markersymbol x:name= "Mypicturemarker" offsetx= "ten" offsety= "ten" >
<esriSymbols:MarkerSymbol.ControlTemplate>
<ControlTemplate>
<rectangle fill= "{StaticResource Myimagebrush}"
Opacity= "0.75" width= "height="/>
</ControlTemplate>
</esriSymbols:MarkerSymbol.ControlTemplate>
</esriSymbols:MarkerSymbol>
</Grid.Resources>

Creation Time: 2009-07-28

Last update: 2010-06-22

Go HOWTO: Replace Picturemarkersymbol with ImageBrush to enhance graphic display performance

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.