AnsweredAssumed Answered

Arc Engine bitmap export issue

Question asked by askltd on May 11, 2016

I have created a map using my own utility to create a personal geodatabase. Part of the program is to export the completed map as bitmaps at different scales, along with this it checks to see if the size of the bitmap is above 3000 pixel and if so, it splits that bitmap up into smaller bitmaps.

 

Whilst the program generally works, it comes up with an issue at times, instead of the polygons being drawn normally in the bitmap, it appears as if the fill routine goes wrong and the bitmap is covered with one of the polygons where it shouldn't, almost like it was inverted.

I have seen this happen a lot in ArcEngine when a layer is stored in the mapping but the layer didn't contain anything. However, this can't be as the issue as the layers all contain information.

I can only think that some how a poly is getting clipped and going wrong in the clip. Does any one know of this issue and how to resolve it,

 

This is the code that I use to export the area in PNG format.

 

private void ExportPng(string dir, string file, int scale, IEnvelope extent,bool split)

        {

            try

            {

                if (!File.Exists(dir + "\\" + file))

                {

                    double width = Math.Round(1 + ((2000.0f * extent.Width) / scale));

                    double height = Math.Round(1 + ((2000.0f * extent.Height) / scale));

 

                    WriteLog("width = " + width);

                    WriteLog("height = " + height);

                  

                    if (split)

                    {

                        if ((width > 3000) || (height > 3000))

                        {

                            WriteLog("creating sub images");

                            int w = (int)(1 + (width / 3000));

                            int h = (int)(1 + (height / 3000));

 

 

                            WriteLog("sub width = " + w);

                            WriteLog("sub height = " + h);

 

                            double ex = extent.Width / w;

                            double ey = extent.Height / h;

 

                            for (int ix = 0; ix < w; ix++)

                            {

                                for (int iy = 0; iy < h; iy++)

                                {

                                    IEnvelope subExtent = new EnvelopeClass();

                                    subExtent.XMin = (extent.XMin + (ix * ex));

                                    subExtent.YMin = (extent.YMin + (iy * ey));

                                    subExtent.XMax = (extent.XMin + ((ix + 1) * ex));

                                    subExtent.YMax = (extent.YMin + ((iy + 1) * ey));

                                    ExportPng(dir, System.IO.Path.GetFileNameWithoutExtension(file) + "_" + ix + "_" + iy + "." + GetSelectedFormat(), scale, subExtent, split);

                                }

                            }

                            return;

                        }

                    }

 

                    IExport m_pExport;

                    IExportPNG m_pExportPNG;

                    //IExportPNG exportPng;

 

                    IWorldFileSettings m_pWorldFileSettings;

                    IWorldFileSettings2 m_pWorldFileSettings2;

                    IExportImage m_pExportImage;

                    IStepProgressor m_pLocalStepProgressor;

 

                    bool m_bActiveViewGeoTiffCapable;

                    //int size = 1024 * scale;

                    IActiveView docActiveView = axMapControl1.ActiveView;

 

 

                    tagRECT exportRECT;

               

                    m_pExport = new ExportPNGClass();

                    m_pExportPNG = (IExportPNG)m_pExport;   

                 

                    m_pWorldFileSettings = (IWorldFileSettings)m_pExport;

                    m_pWorldFileSettings2 = (IWorldFileSettings2)m_pExport;

                    m_pExportImage = (IExportImage)m_pExport;

                    m_bActiveViewGeoTiffCapable = true;

 

 

                    m_pExportImage.ImageType = esriExportImageType.esriExportImageTypeTrueColor;

 

                    m_pWorldFileSettings.OutputWorldFile = true;

 

 

                    m_pWorldFileSettings.MapExtent = extent;

 

 

                    m_pExport.ExportFileName = dir + "\\" + file;

 

                    m_pExportImage.Width = (int)width; //size;

                    m_pExportImage.Height = (int)height; //(int)((size * extent.Height) / extent.Width);

 

                    exportRECT.left = 0;

                    exportRECT.right = (int)width; //size;

                    exportRECT.top = 0;

                    exportRECT.bottom = (int)height;

 

                    int hdc = m_pExport.StartExporting();

                    WriteLog(" start output ");

                    docActiveView.Output((int)hdc, (int)m_pExport.Resolution, ref exportRECT, extent, null);

                    WriteLog("output complete");

 

                    m_pExport.FinishExporting();

                    WriteLog("finished Exporting");

 

                    m_pExport.Cleanup();

                    WriteLog("cleanup complete");

                    GC.Collect();

                }

            }

            catch (Exception ex)

            {

                MessageBox.Show("Error\n" + ex);

                WriteLog("" + ex);

            }

        }

 

If someone can help, with resolving this issue, thanks.

Outcomes