Trann
Trann

Reputation: 3647

Osmdroid: rendering tiles with transparency

I have an mbtiles database with a mixture of jpeg and png tiles. The png tiles are there for transparency reasons, however when they are displayed in osmdroid, the transparent regions are black. Usually black transparency regions indicate that your image is being rendered like a JPEG instead of a format that supports transparency. Also worth noting, the database renders fine in any other viewer I use.

I am fairly new to osmdroid api and codebase, can anyone provide a good place to look or a class name that I could inspect? I have googled this issue extensively and found an example of someone doing something i think is along the right track, but overriding that class doesn't get me png tiles that appear correct.

TIA, Trann

Upvotes: 1

Views: 1466

Answers (1)

Daniel Bartusch
Daniel Bartusch

Reputation: 46

i wrote the blog article you linked and had a look at the osmdroid source but i'm missing some more information about your setup and the tiles you have in your database to find the solution to your problem.

But since you asked for some class names you can inspect i'll try to give you the way your tile will go - then you can look at the code yourself and i hope this helps enough for you to find the reason for the black regions

1) [TilesOverlay.java] requests a tile with coordinates (x,y) and the zoom factor from your Tile Provider #Line 168

2) [MapTileProviderArray] (in case of an other provider you need to find the method "getMapTile" there insead) will try to load the correct tile #Line 121

3) [MapTileModuleProviderBase] will send the Request to your specific tile provider - in your case i guess a file Archive Provider #Line 241

4) [MapTileFileArchiveProvider] gets the Input Stream to the Data from your mbtiles Database #Line 210 & 169

5) [MBTilesFileArchive] reads the database for the requested tile #Line 56

6) [MapTileFileArchiveProvider] requests a bitmap from your specified tileSource #Line 215

7) [BitmapTileSourceBase] uses the Android Class BitmapFactory to create a Bitmap #Line 130

8) [MapTileModuleProviderBase] passes the Bitmap (#Line 210) to your Provider [MapTileProviderArray] (#Line 135) and finally [MapTileProviderBase] adds the Bitmap to the cache and sends a Message to redraw the Tiles (#Line 108 & 113)

Since the cache works with Bitmaps from every tilesource and provider i don't think your problem is further. If the problem would be in the caching of Bitmaps there couldn't be any transparent tiles at all in the whole osmdroid system. So guess your problem is somewhere between these steps.

I hope this helps you to find the problem.

greetings

P.S: Because i'm usually not posting here i have no account and can only give 2 links. All the files i mentioned can be found here: osmdroid trunk

Upvotes: 2

Related Questions