.net

778
1
04-23-2014 03:03 AM
alexzeleksonov
New Contributor
Hi,
I trying to export bmp image from arcmap ,
right noww the i extend the envelop by 5 ,
but i want to export my envelop to the orignal raster  resolution, of the arcmap,
Does Anyone can help? what function should i use to let know to the export class ,
that i need export this image in raster resolution.
Thx For The Help.


tagRECT baseRECT = new tagRECT();
            baseRECT.left = 0;
            baseRECT.top = 0;
            baseRECT.right = 650;
            baseRECT.bottom = 650;
        
            baseRECT = hookHelper.ActiveView.ExportFrame;

            ESRI.ArcGIS.Geometry.IEnvelope envelope = new ESRI.ArcGIS.Geometry.EnvelopeClass();
            envelope.PutCoords(baseRECT.left, baseRECT.top, baseRECT.right, baseRECT.bottom);

            ESRI.ArcGIS.Output.IExport export = new ESRI.ArcGIS.Output.ExportBMPClass();

            export.ExportFileName = pathFileName;
            export.Resolution = 96;
            export.PixelBounds = envelope;
           
            System.Int32 hDC = 0;

            ESRI.ArcGIS.Geometry.IEnvelope ContextEnvelope = expEnvelope.Envelope;
 
            double Max = Math.Max(ContextEnvelope.Width, ContextEnvelope.Height);
            ContextEnvelope.Expand((Max * 5 - ContextEnvelope.Width) / 2, (Max * 5- ContextEnvelope.Height) / 2, false);


            hDC = export.StartExporting();

            try
            {

                hookHelper.ActiveView.Output(hDC, (System.Int16)export.Resolution, ref baseRECT, ContextEnvelope, null);
            }
            catch (Exception ex)
            {
                log.InfoFormat("runDetectionForm_OnPrepareNextFrame, Exception:{0}", ex.Message);
                return false;
            }

            export.FinishExporting();
            export.Cleanup();
0 Kudos
1 Reply
johannesuhl
New Contributor
Hey Alex,
as far as I understand you want to change the resolution of the exported BMP?
you are setting your output resolution to 96 dpi (dots per inch) in this line of your code:

export.Resolution = 96;

the resolution that you see on the monitor depends on screen resolution that you set for your monitor.

look here:
iScreenResolution = GetDeviceCaps(tmpDC, 88)
(from http://help.arcgis.com/en/sdk/10.0/vba_desktop/conceptualhelp/index.html#//0001000000pn000000)

If you use any raster data in ArcMap that you want to export like this, you should consider the original resolution of your raster datasets.
depending on your map scale / extent and the desired resolution you can change this value accordingly.
I think you can access the raster dataset resolution programmatically by IRasterProps

    Dim pRasProp As IRasterProps
    Set pRasProp = pRaster
   
    pRasProp.MeanCellSize  --> thats should be the pixel size of the raster.

Hope this helps.
Regards
0 Kudos