private void BitmapTest() { string sError = ""; try { string sURL = "http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer/export"; string sData = "?f=image"; int iWidth = (int)MyMap.Width; int iHeight = (int)MyMap.Height; sData += "&size=" + iWidth.ToString() + "," + iHeight.ToString(); sData += "&bbox=-121,32,-113,36"; Uri uri = new Uri(sURL + sData); HttpWebRequest req = (HttpWebRequest)WebRequest.Create(uri); req.BeginGetResponse(new AsyncCallback(RespCallback), req); } catch (WebException e) { sError = e.Message; } catch (Exception e) { sError = e.Message; } } private void RespCallback(IAsyncResult ar) { string sError = ""; try { HttpWebRequest req = (HttpWebRequest)ar.AsyncState; HttpWebResponse res = (HttpWebResponse)req.EndGetResponse(ar); if (res.StatusCode == HttpStatusCode.OK) { string sType = res.ContentType; int iLen = (int)res.ContentLength; Stream stream = res.GetResponseStream(); this.Dispatcher.BeginInvoke(() => StreamToBitmap(stream)); } } catch (WebException e) { sError = e.Message; } catch (Exception e) { sError = e.Message; } } private void StreamToBitmap(Stream s) { string sError = ""; try { BitmapImage bmi = new BitmapImage(); bmi.SetSource(s); WriteableBitmap wbm = new WriteableBitmap(bmi); int iWidth = wbm.PixelWidth; int iHeight = wbm.PixelHeight; int i = wbm.Pixels[0]; // Bingo! } catch (Exception e) { sError = e.Message; } }
Is there any way in REST/Silverlight to export a map to an image file? WriteableBitmap won't allow access to content from a UI element that uses URL-derived properties.
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.