1

I am attempting to download a number of images to use as custom tiles for Google Maps. I am downloading the tiles as a byte[] using the code:

 using (WebClient webClient = new WebClient())
 {
     var response = webClient.DownloadData(new Uri(url));
     return response;
 }

Then I save the byte[] directly to my SQLite database:

TileData t = new TileData();
t.X = x;
t.Y = y;
t.Zoom = zoom;
t.Data = byteData;

conn.Insert(t);

Finally, in my custom TileProvider class in the overrided GetTile method, I create a tile using the byte[] saved in the SQLite db:

public Tile GetTile(int x, int y, int zoom)
{
   byte[] bitmap = RetreiveImage(x, y, zoom);

   Tile tile = new Tile(_width, _height, bitmap);

   return tile;
}

My problem is, when tiles are retrieved for overlay, I get the error:
"[skia] failed to create image decoder with message 'unimplemented'"

I have been struggling to figure out what is wrong. I assume my byte[] is in an invalid format but I do not know why.

The images I am downloading are .jfif, although from what I can tell .jfif is the same as .jpeg so it shouldnt be a problem.

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
Bouapha
  • 31
  • 3
  • 1
    is this a runtime exception? Or just a console error message? If it's an exception, which line is causing it and what does the stack trace show? – Jason Feb 01 '22 at 13:19
  • It is a console error deriving from the GetTile method, presumably when the Tile object is created. The custom TileProvider (used in the custom Map Renderer as a TileOverlay) calls GetTile – Bouapha Feb 01 '22 at 13:46
  • var tileProvider = new CustomMapTileProvider(256, 256); var options = new TileOverlayOptions().InvokeTileProvider(tileProvider); this.NativeMap.AddTileOverlay(options); – Bouapha Feb 01 '22 at 13:48
  • are you **positive** that your `byte[]` contains valid image data in a format supported by Skia? – Jason Feb 01 '22 at 13:54
  • 1
    Sorry I was misinformed about jfif, it is a more complex subset of jpeg but not the same thing. Saving the jfif byte[] as a jpeg and then reading the saved file as a byte[] did the trick, thanks. – Bouapha Feb 01 '22 at 15:55

0 Answers0