Пример #1
0
        public static Bitmap DownloadImageFromTile(TileBlock block, bool getBitmap)
        {
            try
            {
                var oRequest  = MapUtilities.CreateTileWebRequest(block);
                var oResponse = (HttpWebResponse)oRequest.GetResponse();

                var bmpStream = new MemoryStream();
                var oStream   = oResponse.GetResponseStream();
                if (oStream != null)
                {
                    oStream.CopyTo(bmpStream);
                }
                oResponse.Close();
                if (bmpStream.Length > 0)
                {
                    WriteImageToFile(block, bmpStream);
                    return(getBitmap ? (Bitmap)Image.FromStream(bmpStream) : null);
                }
            }
            catch (Exception ex)
            {
                //do nothing
                System.Diagnostics.Trace.WriteLine(ex.Message);
            }
            return(null);
        }