<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: PictureMarkerSymbol's Source from SymbolDictionary in ArcGIS Runtime SDK for WPF (Retired) Questions</title>
    <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/picturemarkersymbol-s-source-from-symboldictionary/m-p/375147#M1858</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;{"Specified method is not supported."}&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Unfortunately this way of creating a PictureMarkerSymbol does not work in accelerated display, as the ImageSource object does not have a Url from which the image's raw image bytes can be obtained.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To work around this problem you could save the ImageSource that you get from SymbolProperties.GetImage to disk as a PNG file, and then create a PictureMarkerSymbol with an ImageSource with a Uri set to the file path of the saved image file.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;//helper method for getting PNG bytes for a BitmapSource

&amp;nbsp; static byte[] GetPngBytes(BitmapSource image)
&amp;nbsp; {
&amp;nbsp;&amp;nbsp; using (MemoryStream ms = new MemoryStream())
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; PngBitmapEncoder encoder = new PngBitmapEncoder();
&amp;nbsp;&amp;nbsp;&amp;nbsp; encoder.Frames.Add(BitmapFrame.Create(image));
&amp;nbsp;&amp;nbsp;&amp;nbsp; encoder.Save(ms);
&amp;nbsp;&amp;nbsp;&amp;nbsp; byte[] buffer = ms.GetBuffer();
&amp;nbsp;&amp;nbsp;&amp;nbsp; return buffer;
&amp;nbsp;&amp;nbsp; }
&amp;nbsp; }

&amp;nbsp; ...

&amp;nbsp; ImageSource imageSource = list[0].GetImage(30, 30);

&amp;nbsp; string pngPath = "...";

&amp;nbsp; File.WriteAllBytes(pngPath, GetPngBytes((BitmapSource)imageSource));

&amp;nbsp; var s = new PictureMarkerSymbol {Source=new BitmapImage(new Uri(pngPath)) };

&amp;nbsp; ...&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 17:21:06 GMT</pubDate>
    <dc:creator>InnesMacKenzie</dc:creator>
    <dc:date>2021-12-11T17:21:06Z</dc:date>
    <item>
      <title>PictureMarkerSymbol's Source from SymbolDictionary</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/picturemarkersymbol-s-source-from-symboldictionary/m-p/375146#M1857</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm trying to get the image from the SymbolDictionary and use it on a PictureMarkerSymbol. When I run my app it generates an error. Here is the code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;SymbolDictionary symbolDictionary = new SymbolDictionary(SymbolDictionaryType.Mil2525C);

 IEnumerable&amp;lt;string&amp;gt; enumSymbol = new List&amp;lt;string&amp;gt;() { "SHGP-----------" };
IList&amp;lt;SymbolProperties&amp;gt; list = symbolDictionary.FindSymbols(enumSymbol);

 ImageSource imageSource = list[0].GetImage(30, 30);

PictureMarkerSymbol pictureMarkerSymbol2 = new PictureMarkerSymbol()
{
Source = imageSource
 };&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is the error that I get once my app starts:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;{"Specified method is not supported."}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There is not an error if I step right over the Source. In fact, it seems OK. It's only when the app is nearly open that this error occurs.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Ron&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Nov 2012 16:49:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/picturemarkersymbol-s-source-from-symboldictionary/m-p/375146#M1857</guid>
      <dc:creator>RonVincent</dc:creator>
      <dc:date>2012-11-06T16:49:45Z</dc:date>
    </item>
    <item>
      <title>Re: PictureMarkerSymbol's Source from SymbolDictionary</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/picturemarkersymbol-s-source-from-symboldictionary/m-p/375147#M1858</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;{"Specified method is not supported."}&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Unfortunately this way of creating a PictureMarkerSymbol does not work in accelerated display, as the ImageSource object does not have a Url from which the image's raw image bytes can be obtained.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To work around this problem you could save the ImageSource that you get from SymbolProperties.GetImage to disk as a PNG file, and then create a PictureMarkerSymbol with an ImageSource with a Uri set to the file path of the saved image file.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;//helper method for getting PNG bytes for a BitmapSource

&amp;nbsp; static byte[] GetPngBytes(BitmapSource image)
&amp;nbsp; {
&amp;nbsp;&amp;nbsp; using (MemoryStream ms = new MemoryStream())
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; PngBitmapEncoder encoder = new PngBitmapEncoder();
&amp;nbsp;&amp;nbsp;&amp;nbsp; encoder.Frames.Add(BitmapFrame.Create(image));
&amp;nbsp;&amp;nbsp;&amp;nbsp; encoder.Save(ms);
&amp;nbsp;&amp;nbsp;&amp;nbsp; byte[] buffer = ms.GetBuffer();
&amp;nbsp;&amp;nbsp;&amp;nbsp; return buffer;
&amp;nbsp;&amp;nbsp; }
&amp;nbsp; }

&amp;nbsp; ...

&amp;nbsp; ImageSource imageSource = list[0].GetImage(30, 30);

&amp;nbsp; string pngPath = "...";

&amp;nbsp; File.WriteAllBytes(pngPath, GetPngBytes((BitmapSource)imageSource));

&amp;nbsp; var s = new PictureMarkerSymbol {Source=new BitmapImage(new Uri(pngPath)) };

&amp;nbsp; ...&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:21:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/picturemarkersymbol-s-source-from-symboldictionary/m-p/375147#M1858</guid>
      <dc:creator>InnesMacKenzie</dc:creator>
      <dc:date>2021-12-11T17:21:06Z</dc:date>
    </item>
  </channel>
</rss>

