if (bClipToGraphicsExtent && (docActiveView is IPageLayout)) { docGraphicsExtentEnv = GetGraphicsExtent(docActiveView); docPageLayout = docActiveView as PageLayout; pUnitConvertor = new UnitConverter();
//assign the x and y values representing the clipped area to the PixelBounds envelope PixelBoundsEnv.XMin = 0; PixelBoundsEnv.YMin = 0; PixelBoundsEnv.XMax = pUnitConvertor.ConvertUnits(docGraphicsExtentEnv.XMax, docPageLayout.Page.Units, esriUnits.esriInches) * docExport.Resolution - pUnitConvertor.ConvertUnits(docGraphicsExtentEnv.XMin,
docPageLayout.Page.Units, esriUnits.esriInches) * docExport.Resolution; PixelBoundsEnv.YMax = pUnitConvertor.ConvertUnits(docGraphicsExtentEnv.YMax, docPageLayout.Page.Units, esriUnits.esriInches) * docExport.Resolution - pUnitConvertor.ConvertUnits(docGraphicsExtentEnv.YMin,
docPageLayout.Page.Units, esriUnits.esriInches) * docExport.Resolution;
//'assign the x and y values representing the clipped export extent to the exportRECT exportRECT.bottom = (int)(PixelBoundsEnv.YMax) + 1; exportRECT.left = (int)(PixelBoundsEnv.XMin); exportRECT.top = (int)(PixelBoundsEnv.YMin); exportRECT.right = (int)(PixelBoundsEnv.XMax) + 1;
//since we're clipping to graphics extent, set the visible bounds. docMapExtEnv = docGraphicsExtentEnv; } else { double tempratio = iOutputResolution / iScreenResolution; double tempbottom = DisplayBounds.bottom * tempratio; double tempright = DisplayBounds.right * tempratio; //'The values in the exportRECT tagRECT correspond to the width //and height to export, measured in pixels with an origin in the top left corner. exportRECT.bottom = (int)Math.Truncate(tempbottom); exportRECT.left = 0; exportRECT.top = 0; exportRECT.right = (int)Math.Truncate(tempright);
//populate the PixelBounds envelope with the values from exportRECT. // We need to do this because the exporter object requires an envelope object // instead of a tagRECT structure. PixelBoundsEnv.PutCoords(exportRECT.left, exportRECT.top, exportRECT.right, exportRECT.bottom);
//since it's a page layout or an unclipped page layout we don't need docMapExtEnv. docMapExtEnv = null; }
// Assign the envelope object to the exporter object's PixelBounds property. The exporter object // will use these dimensions when allocating memory for the export file. docExport.PixelBounds = PixelBoundsEnv;