<?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: Semi-transparent picture symbols in ArcObjects in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/semi-transparent-picture-symbols-in-arcobjects/m-p/525068#M14162</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The &lt;A href="http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/index.html#//001w0000026r000000"&gt;IPictureMarkerSymbol.CreateMarkerSymbolFromFile&lt;/A&gt; Method has a PNG in its esriIPictureType parameter.&lt;BR /&gt;I just tried it using this &lt;A href="http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/index.html#//00490000004n000000"&gt;Snippet &lt;/A&gt;and It works fine.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 01 Dec 2014 09:28:08 GMT</pubDate>
    <dc:creator>AhmedEl-Sisi</dc:creator>
    <dc:date>2014-12-01T09:28:08Z</dc:date>
    <item>
      <title>Semi-transparent picture symbols in ArcObjects</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/semi-transparent-picture-symbols-in-arcobjects/m-p/525067#M14161</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When creating a new point layer with picture symbols in ArcMap 10.2.1 using ArcObjects, I have tried several ways to load semi-transparent symbol images from .png files, but to no avail, the transparency is always lost and appearing opaque.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since IPictureMarkerSymbol.CreateMarkerSymbolFromFile doesn't handle .png, I think I will have to create the IPictureDisp myself. I know it should work somehow, since I can load the same semi-transparent .png file manually in the picture symbol in ArcMap, resulting in correct semi-transparency. And I know about the support for setting a transparency color, but it wouldn't handle semi-transparency.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My current solution, inspired from &lt;A href="http://gis.stackexchange.com/questions/22037/arcobjects-setting-image-of-a-command-button-to-a-partially-transparent-bitmap" rel="nofollow noopener noreferrer" target="_blank"&gt;this post&lt;/A&gt;, goes something like this (except for the creation of the actual layer) but doesn't work either:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;class IPictureDispConverter
{
&amp;nbsp; public static Guid iPictureDispGuid = typeof(stdole.IPictureDisp).GUID;
&amp;nbsp; /// Converts an Icon into a IPictureDisp
&amp;nbsp; public static IPictureDisp ConvertBitmapToIPictureDisp(Bitmap bitmap)
&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; PICTDESC.Bitmap pictBit = new PICTDESC.Bitmap(bitmap);
&amp;nbsp;&amp;nbsp;&amp;nbsp; return OleCreatePictureIndirect(pictBit, ref iPictureDispGuid, true);
&amp;nbsp; }
&amp;nbsp; [DllImport("OleAut32.dll", EntryPoint = "OleCreatePictureIndirect", ExactSpelling = true, PreserveSig = false)]
&amp;nbsp; private static extern stdole.IPictureDisp OleCreatePictureIndirect([MarshalAs(UnmanagedType.AsAny)] object picdesc, ref Guid iid, bool fOwn);
&amp;nbsp; // WINFORMS COMMENT:
&amp;nbsp; // PICTDESC is a union in native, so we'll just
&amp;nbsp; // define different ones for the different types
&amp;nbsp; // the "unused" fields are there to make it the right
&amp;nbsp; // size, since the struct in native is as big as the biggest
&amp;nbsp; // union.
&amp;nbsp; private static class PICTDESC
&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; //Picture Types
&amp;nbsp;&amp;nbsp;&amp;nbsp; public const short PICTYPE_UNINITIALIZED = -1;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public const short PICTYPE_NONE = 0;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public const short PICTYPE_BITMAP = 1;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public const short PICTYPE_METAFILE = 2;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public const short PICTYPE_ICON = 3;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public const short PICTYPE_ENHMETAFILE = 4;
&amp;nbsp;&amp;nbsp;&amp;nbsp; [StructLayout(LayoutKind.Sequential)]
&amp;nbsp;&amp;nbsp;&amp;nbsp; public class Icon
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; internal int cbSizeOfStruct = Marshal.SizeOf(typeof(PICTDESC.Icon));
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; internal int picType = PICTDESC.PICTYPE_ICON;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; internal IntPtr hicon = IntPtr.Zero;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; internal int unused1 = 0;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; internal int unused2 = 0;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; internal Icon(System.Drawing.Icon icon)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.hicon = icon.ToBitmap().GetHicon();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; [StructLayout(LayoutKind.Sequential)]
&amp;nbsp;&amp;nbsp;&amp;nbsp; public class Bitmap
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; internal int cbSizeOfStruct = Marshal.SizeOf(typeof(PICTDESC.Bitmap));
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; internal int picType = PICTDESC.PICTYPE_BITMAP;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; internal IntPtr hbitmap = IntPtr.Zero;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; internal IntPtr hpal = IntPtr.Zero;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; internal int unused = 0;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; internal Bitmap(System.Drawing.Bitmap bitmap)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.hbitmap = bitmap.GetHbitmap();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp; }
}
// FROM ANOTHER PART OF THE CODE:
IPictureMarkerSymbol markerSymbol = new PictureMarkerSymbolClass();
Bitmap bitmap = new Bitmap(pngFilename);
markerSymbol.Picture = IPictureDispConverter.ConvertBitmapToIPictureDisp(bitmap);
ISimpleRenderer renderer = new SimpleRendererClass();
((IGeoFeatureLayer)layer).Renderer = renderer as IFeatureRenderer;
renderer.Symbol = markerSymbol.Picture as ISymbol;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the result with my code:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Doesn't work" class="jive-image" src="http://i.stack.imgur.com/QlUuS.jpg" /&gt;&lt;/P&gt;&lt;P&gt;And here it is when I have pointed out the same .png file manually for the same layer in ArcMap afterwards:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Works" class="jive-image" src="http://i.stack.imgur.com/Zu8oj.jpg" /&gt;&lt;/P&gt;&lt;P&gt;Does anyone know how to do this properly?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:53:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/semi-transparent-picture-symbols-in-arcobjects/m-p/525067#M14161</guid>
      <dc:creator>AndreasEkstrand</dc:creator>
      <dc:date>2021-12-11T22:53:31Z</dc:date>
    </item>
    <item>
      <title>Re: Semi-transparent picture symbols in ArcObjects</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/semi-transparent-picture-symbols-in-arcobjects/m-p/525068#M14162</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The &lt;A href="http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/index.html#//001w0000026r000000"&gt;IPictureMarkerSymbol.CreateMarkerSymbolFromFile&lt;/A&gt; Method has a PNG in its esriIPictureType parameter.&lt;BR /&gt;I just tried it using this &lt;A href="http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/index.html#//00490000004n000000"&gt;Snippet &lt;/A&gt;and It works fine.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Dec 2014 09:28:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/semi-transparent-picture-symbols-in-arcobjects/m-p/525068#M14162</guid>
      <dc:creator>AhmedEl-Sisi</dc:creator>
      <dc:date>2014-12-01T09:28:08Z</dc:date>
    </item>
    <item>
      <title>Re: Semi-transparent picture symbols in ArcObjects</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/semi-transparent-picture-symbols-in-arcobjects/m-p/525069#M14163</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Wow, thanks Ahmed - it actually works. I was fooled by this in the CreateMarkerSymbolFromFile doc:&lt;/P&gt;&lt;P&gt; &lt;STRONG&gt;&lt;EM&gt;Supported types are esriIPictureBitmap (bitmap images) and esriIPictureEMF (emf files).&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And it didn't work when I tried it before, but probably due to some other error. Anyway, problem solved!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Dec 2014 07:50:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/semi-transparent-picture-symbols-in-arcobjects/m-p/525069#M14163</guid>
      <dc:creator>AndreasEkstrand</dc:creator>
      <dc:date>2014-12-03T07:50:19Z</dc:date>
    </item>
  </channel>
</rss>

