arcgis engine鎸囧畾鑼冨洿瀵煎嚭灞忓箷鍥剧墖
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了arcgis engine鎸囧畾鑼冨洿瀵煎嚭灞忓箷鍥剧墖相关的知识,希望对你有一定的参考价值。
鏍囩锛?a href='http://www.mamicode.com/so/1/top' title='top'>top
splay gif cer length substring image time scl鍦扮悊鍧愭爣涓嬶紝鎵€浠ヨ杞崲涓哄害銆?/p>
arcgis engine 10.2.2 +vs2010
[DllImport("GDI32.dll")] public static extern int GetDeviceCaps(int hdc, int nIndex); /* User32 delegates to getDC and ReleaseDC */ [DllImport("User32.dll")] public static extern int GetDC(int hWnd); [DllImport("User32.dll")] public static extern int ReleaseDC(int hWnd, int hDC); [DllImport("user32.dll", SetLastError = true)] static extern bool SystemParametersInfo(uint uiAction, uint uiParam, ref int pvParam, uint fWinIni); /// <summary> /// 鍦板浘璺濈杞睆骞曞儚绱犳暟,涓嶅悓缂╂斁姣斾緥灏轰笅鍚屾牱璺濈瀵瑰簲鍍忕礌鏁颁笉鍚岀殑锛屾湁鐗规畩闇€瑕佹椂璁剧疆sMapBLC /// </summary> /// <param name="pAV">The p AV.</param> /// <param name="dMapUnits">鍦板浘璺濈</param> /// <returns></returns> public static double ConvertMapUnitsToPixels(IActiveView pAV, double dMapUnits) { IDisplayTransformation pDT = pAV.ScreenDisplay.DisplayTransformation; tagRECT pDeviceFrame = pDT.get_DeviceFrame(); int iDeviceLeft = pDeviceFrame.left; int iDeviceRight = pDeviceFrame.right; int iPixelExtent = iDeviceRight - iDeviceLeft; double dRealWorldExtent = pAV.Extent.Width; double dSizeOfEachPixel = dRealWorldExtent / iPixelExtent; return dMapUnits / dSizeOfEachPixel; } /// <summary> /// 鎸囧畾鑼冨洿瑁佸壀鍥剧墖 /// </summary> /// <param name="pMap">瑁佸浘鍦板浘绐楀彛</param> /// <param name="pExtent">鎸囧畾瑁佸浘鑼冨洿</param> /// <param name="strPicFile">杈撳嚭鏂囦欢鍚嶇О</param> /// <param name="iOutResolution">杈撳嚭DPI</param> public static void ClipMap2Pic(IActiveView pAV, IEnvelope pExtent, string strPicFile, int iOutResolution) { if (pAV == null) return; if (strPicFile == string.Empty) return; string ext = strPicFile.Substring(strPicFile.Length - 4).ToUpper(); IExport pExport = null; if (ext == ".TIF") //鏍规嵁鏂囦欢鍚嶅悗4浣嶅垽鏂緭鍑虹被鍨?/span> pExport = new ExportTIFFClass(); else if (ext == ".EMF") pExport = new ExportEMFClass(); else if (ext == ".BMP") pExport = new ExportBMPClass(); else if (ext == ".GIF") pExport = new ExportGIFClass(); else if (ext == ".PDF") pExport = new ExportPDFClass(); else if (ext == ".PNG") pExport = new ExportPNGClass(); else if (ext == ".SVG") pExport = new ExportSVGClass(); else if (strPicFile.Substring(strPicFile.Length - 4).ToUpper() == ".AI") pExport = new ExportAIClass(); else if (ext == ".EPS") pExport = new ExportPSClass(); else pExport = new ExportJPEGClass(); IDisplayTransformation pDT = pAV.ScreenDisplay.DisplayTransformation; IOutputRasterSettings docOutputRasterSettings = pDT as IOutputRasterSettings; int iPrevOutputImageQuality = docOutputRasterSettings.ResampleRatio; docOutputRasterSettings.ResampleRatio = 1; /* Get the device context of the screen */ long tmpDC = GetDC(0); /* Get the screen resolution. */ int iScreenResolution = GetDeviceCaps((int)tmpDC, 88); //88 is the win32 const for Logical pixels/inch in X) /* release the DC. */ ReleaseDC(0, (int)tmpDC); // 鏍规嵁浼犲叆鐨刾Extent纭畾瑁佸浘鐨勭敾甯冨ぇ灏忥紙鍑哄浘姣斾緥灏轰笅瑁佸浘鑼冨洿鐨勫儚绱犻珮鍜屽锛?/span> tagRECT ptagTmp; ptagTmp.left = 0; ptagTmp.top = 0; ptagTmp.right = (int)Math.Truncate(ConvertMapUnitsToPixels(pAV, pExtent.Width) * iOutResolution / iScreenResolution); //鎶婂湴鍥捐窛绂昏浆涓哄睆骞曞儚绱犱釜鏁?/span> ptagTmp.bottom = (int)Math.Truncate(ConvertMapUnitsToPixels(pAV, pExtent.Height) * iOutResolution / iScreenResolution); IEnvelope pEnvNew = new EnvelopeClass(); pEnvNew.PutCoords(ptagTmp.left, ptagTmp.top, ptagTmp.right, ptagTmp.bottom); //瑁佸浘鐨勭敾甯冨ぇ灏?/span> pExport.ExportFileName = strPicFile; pExport.Resolution = iOutResolution; pExport.PixelBounds = pEnvNew; if (ext == ".TIF") { (pExport as IExportTIFF).GeoTiff = true;//鍖呭惈tif鏂囦欢鍧愭爣淇℃伅锛岃繖2鍙ユ槸蹇呴』鐨?/span> (pExport as IWorldFileSettings).MapExtent = pExtent; (pExport as IExportTIFF).CompressionType = esriTIFFCompression.esriTIFFCompressionJPEG; } if (ext == ".PDF") { (pExport as IExportPDF).Compressed = true; (pExport as IExportPDF).EmbedFonts = true; (pExport as IExportPDF).ImageCompression = esriExportImageCompression.esriExportImageCompressionNone; } int ihdc = pExport.StartExporting(); pAV.Output(ihdc, iOutResolution, ref ptagTmp, pExtent, null); pExport.FinishExporting(); pExport.Cleanup(); (pDT as IOutputRasterSettings).ResampleRatio = iPrevOutputImageQuality; } void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e) { if (isExportMode) { IEnvelope bounds = new EnvelopeClass(); double dis = 100;//100绫?/span> IUnitConverter convert = new UnitConverterClass(); double degree = convert.ConvertUnits(dis, esriUnits.esriMeters, esriUnits.esriDecimalDegrees);//杞崲涓哄害 bounds.PutCoords(e.mapX - degree, e.mapY + degree, e.mapX + degree, e.mapY - degree); string file = System.IO.Path.Combine(@"D: est22image", DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".jpg"); ClipMap2Pic(this.axMapControl1.ActiveView, bounds, file, 96); } }
以上是关于arcgis engine鎸囧畾鑼冨洿瀵煎嚭灞忓箷鍥剧墖的主要内容,如果未能解决你的问题,请参考以下文章
MongoDB mongoimport 浠巆sv瀵煎叆鏁版嵁鎸囧畾瀛楁绫诲瀷