<?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 How to export transparent images from IMapServer2 in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-export-transparent-images-from-imapserver2/m-p/580380#M15691</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to export image tiles from ArcMap to be used as overlays in my application. I utilize IMapServer.ExportMapImage for this purpose. It works just fine with the exception of the layers with Opacity/Transparency setting. The generated tiles are all opaque regardless of the layers opacity settings.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It is stated in the &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/ExportMapImage_Method/001200000m3p000000/" rel="nofollow noopener noreferrer" target="_blank"&gt;API Reference&lt;/A&gt;&lt;SPAN&gt; that:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[INDENT]&lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;Optimized MapServices add support for the image type PNG32 which allows the use of an alpha band (in addition to RGB bands) to support pixel level transparency. When using the PNG32 format, transparency set on layers in the map gets carried over to the output image.&amp;nbsp; This means that the client application does not need to set any client side transparency when draping the service on top of another map service. Use the ServiceConfigurationInfo property set to find out whether a map service supports PNG32.&lt;/SPAN&gt;&lt;SPAN&gt;[/INDENT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does anybody here have any idea to what I am doing wrong here?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
mapServer = new MapServerClass();
mapServer.Connect(mapPath);
mapInfo = mapServer.GetServerInfo(mapServer.get_MapName(0));
mapDesc = mapInfo.DefaultMapDescription; 

ImageType imgType = new ImageType();
imgType.Format = esriImageFormat.esriImagePNG32;
imgType.ReturnType = esriImageReturnType.esriImageReturnMimeData;

IImageDisplay2 imgDisp = new ImageDisplay() as IImageDisplay2;
imgDisp.DeviceResolution = EXPORT_DPI;
imgDisp.Height = EDGE_SIZE;
imgDisp.Width = EDGE_SIZE;
imgDisp.TransparentColor = mapInfo.BackgroundColor;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 

ImageDescription imgDesc = new ImageDescription();
imgDesc.Display = imgDisp as IImageDisplay;
imgDesc.Type = imgType;

mapDesc .MapArea = createMapArea(...);
mapDescription.TransparentColor = mapInfo.BackgroundColor;&amp;nbsp;&amp;nbsp; 
IMapImage mapImg = mapServer.ExportMapImage(mapDescription, imageDescription);

using (BinaryWriter writer = new BinaryWriter(File.Open(filePath, FileMode.Create)))
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; writer.Write(tileImageData);
}

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Best regards and thanks in advance&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Yashar Moradi&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 00:57:41 GMT</pubDate>
    <dc:creator>RomanWössner2</dc:creator>
    <dc:date>2021-12-12T00:57:41Z</dc:date>
    <item>
      <title>How to export transparent images from IMapServer2</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-export-transparent-images-from-imapserver2/m-p/580380#M15691</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to export image tiles from ArcMap to be used as overlays in my application. I utilize IMapServer.ExportMapImage for this purpose. It works just fine with the exception of the layers with Opacity/Transparency setting. The generated tiles are all opaque regardless of the layers opacity settings.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It is stated in the &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/ExportMapImage_Method/001200000m3p000000/" rel="nofollow noopener noreferrer" target="_blank"&gt;API Reference&lt;/A&gt;&lt;SPAN&gt; that:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[INDENT]&lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;Optimized MapServices add support for the image type PNG32 which allows the use of an alpha band (in addition to RGB bands) to support pixel level transparency. When using the PNG32 format, transparency set on layers in the map gets carried over to the output image.&amp;nbsp; This means that the client application does not need to set any client side transparency when draping the service on top of another map service. Use the ServiceConfigurationInfo property set to find out whether a map service supports PNG32.&lt;/SPAN&gt;&lt;SPAN&gt;[/INDENT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does anybody here have any idea to what I am doing wrong here?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
mapServer = new MapServerClass();
mapServer.Connect(mapPath);
mapInfo = mapServer.GetServerInfo(mapServer.get_MapName(0));
mapDesc = mapInfo.DefaultMapDescription; 

ImageType imgType = new ImageType();
imgType.Format = esriImageFormat.esriImagePNG32;
imgType.ReturnType = esriImageReturnType.esriImageReturnMimeData;

IImageDisplay2 imgDisp = new ImageDisplay() as IImageDisplay2;
imgDisp.DeviceResolution = EXPORT_DPI;
imgDisp.Height = EDGE_SIZE;
imgDisp.Width = EDGE_SIZE;
imgDisp.TransparentColor = mapInfo.BackgroundColor;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 

ImageDescription imgDesc = new ImageDescription();
imgDesc.Display = imgDisp as IImageDisplay;
imgDesc.Type = imgType;

mapDesc .MapArea = createMapArea(...);
mapDescription.TransparentColor = mapInfo.BackgroundColor;&amp;nbsp;&amp;nbsp; 
IMapImage mapImg = mapServer.ExportMapImage(mapDescription, imageDescription);

using (BinaryWriter writer = new BinaryWriter(File.Open(filePath, FileMode.Create)))
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; writer.Write(tileImageData);
}

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Best regards and thanks in advance&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Yashar Moradi&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:57:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-export-transparent-images-from-imapserver2/m-p/580380#M15691</guid>
      <dc:creator>RomanWössner2</dc:creator>
      <dc:date>2021-12-12T00:57:41Z</dc:date>
    </item>
  </channel>
</rss>

