I have a task to convert dimension feature into image with ArcObjects.

I need to get real image that I see in ArcMap (with right size and spatial reference, of course) instead of turning feature into raster by values of some field.

Is it possible to perform feature-to-image conversion with ArcObjects?

I need solution applicable to just dimension feature class, not to layer on the map.

It seems that the IDimensionGraphic interface should be used. But I don't understand what arguments should be passed to its Draw method.

closed as off-topic by PolyGeo Jun 15 '18 at 0:08

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "When seeking help to debug/write/improve code always provide the desired behavior, a specific problem/error and the shortest code (as formatted text, not pictures) needed to reproduce it in the question body. Providing a clear problem statement and a code attempt helps others to help you." – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.


Not so long ago I have done something like this with ExportTIFF. You can load the feature to map, zoom to it and then do sth. like this:

ExportTIFF docExport = new ExportTIFFClass();
(docExport as IExport).Resolution = (short)iOutputResolution;

(docExport as IExport).PixelBounds = PixelBoundsEnv;
(docExport as IExport).ExportFileName = sOutputDir + ...

(docExport as IExportTIFF).GeoTiff = true;
(docExport as IWorldFileSettings).MapExtent = docMapExtEnv;
(docExport as IWorldFileSettings).OutputWorldFile = true;

if (docExport is IExportImage)
    (docExport as IExportImage).ImageType = esriExportImageType.esriExportImageTypeIndexed;
   if (docActiveView.ScreenDisplay is IScreenDisplay2)
        IColor col = new RgbColorClass();
        col.RGB=(docActiveView.ScreenDisplay as IScreenDisplay2).BackgroundRGB;
        (docExport as IExportImage).BackgroundColor = col;
long hdc = (docExport as IExport).StartExporting();

IEnvelope dummy = null;
docActiveView.Output((int)hdc, (System.Int16)((docExport as IExport).Resolution), ref exportRECT, docMapExtEnv, null);

(docExport as IExport).FinishExporting();
(docExport as IExport).Cleanup();
  • Thank you for your answer. Unfortunately this code won't work without document (and thereby without map), for example, in geoprocessing function in background mode. I need solution applicable to just dimension feature class, not to layer on the map. I've updated my question to reflect this requirement. – Maxim Mar 11 '16 at 4:58

IDimensionGraphic.Draw requires an ITransformation and hDC, a device context.

The device context can be obtained using the win32 method GetDC, or as it says for IDisplay.StartDrawing,

call IDisplay::StartDrawing with a value of 0 for the hDC as this will automatically use the Windows API function GetDC to populate IScreenDisplay::WindowDC with the hDC of the main display

This might also work for IDimensionGraphic::Draw. It's worth a try.

  • Thank you. Can you provide code of method to save dimension feature into image? Something like DimensionToImage(IDimensionFeature feature, string filePath) { ... } – Maxim Mar 17 '16 at 4:20

Not the answer you're looking for? Browse other questions tagged or ask your own question.