|
6 | 6 | using OxyPlot.Axes; |
7 | 7 | using OxyPlot.Data; |
8 | 8 | using OxyPlot.Legends; |
| 9 | +using OxyPlot.Series; |
9 | 10 | using ReactiveUI; |
10 | 11 | using System; |
11 | 12 | using System.IO; |
@@ -68,28 +69,35 @@ private PlotModel CreateMapPlotView() |
68 | 69 |
|
69 | 70 | var tileMapImageProvider = new HttpTileMapImageProvider(SynchronizationContext.Current) |
70 | 71 | { |
| 72 | + //Url = "https://www.metoffice.gov.uk/public/tiles/map/{Z}/{Y}/{X}.png", |
71 | 73 | Url = "http://tile.openstreetmap.org/{Z}/{X}/{Y}.png", |
72 | 74 | //Url = "https://server.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/tile/{Z}/{Y}/{X}", // https://developers.arcgis.com/documentation/mapping-apis-and-services/data-hosting/services/image-tile-service/ |
73 | 75 | //Url = "https://maptiles.finncdn.no/tileService/1.0.3/norortho/{Z}/{X}/{Y}.png", |
74 | 76 | //Url = "https://maptiles.finncdn.no/tileService/1.0.3/normap/{Z}/{X}/{Y}.png", |
75 | 77 |
|
76 | 78 | MaxNumberOfDownloads = 2, |
77 | 79 | UserAgent = "OxyPlot.Cartography", |
78 | | - ImageConverter = new Func<byte[], byte[]>(input => |
| 80 | + ImageConverter = new Func<byte[], byte[]>(bytes => |
79 | 81 | { |
80 | | - // Only convert if file format is Jpeg |
81 | 82 | // https://github.com/oxyplot/oxyplot/blob/205e968870c292ecaeab2cb9e7f34904897126cb/Source/OxyPlot/Imaging/OxyImage.cs#L221 |
82 | | - if (input.Length >= 2 && input[0] == 0xFF && input[1] == 0xD8) |
| 83 | + if (bytes.Length >= 2 && bytes[0] == 0x42 && bytes[1] == 0x4D) |
| 84 | + { |
| 85 | + return bytes; // Bmp |
| 86 | + } |
| 87 | + |
| 88 | + if (bytes.Length >= 4 && bytes[0] == 0x89 && bytes[1] == 0x50 && bytes[2] == 0x4E && bytes[3] == 0x47) |
83 | 89 | { |
84 | | - using (var msInput = new MemoryStream(input)) |
85 | | - using (var msOutput = new MemoryStream()) |
86 | | - { |
87 | | - var bitmap = Bitmap.DecodeToWidth(msInput, 256); |
88 | | - bitmap.Save(msOutput); |
89 | | - return msOutput.ToArray(); |
90 | | - } |
| 90 | + return bytes; //Png |
| 91 | + } |
| 92 | + |
| 93 | + using (var msInput = new MemoryStream(bytes)) |
| 94 | + using (var msOutput = new MemoryStream()) |
| 95 | + { |
| 96 | + var bitmap = Bitmap.DecodeToWidth(msInput, 256); |
| 97 | + bitmap.Save(msOutput); |
| 98 | + return msOutput.ToArray(); |
91 | 99 | } |
92 | | - return input; |
| 100 | + return bytes; |
93 | 101 | }) |
94 | 102 | }; |
95 | 103 |
|
|
0 commit comments