Currently generating PNG raster tiles (mapnik) with custom style where I store one information (map_feature) by channel (rgba).
Mapnik seems to multiply alpha with value of red, green or blue. I completly understand the rendering engine case seeing 0 as alpha interpreting as full transparent pixel. I just need it to write the color value anyway.
More explanations on my setup :

I have an OSM Database to deliver PNG raster tiles. Nothing much to say about the setup - It's working perfectly.

  • PostgreSQL
  • Mod_tile
  • Mapnik

I've setup a new style based on osm-bright in order to display one type of information by channel :

  • Channel Red rgba(255,0,0,1) --> Rivers
  • Channel Green rgba(0,255,0,1) --> Water_areas
  • Channel Blue rgba(0,0,255,1) --> Forest

Using alpha as 1 and with 3 informations works.
However when i try to swap alpha channel to 0 and add info in alpha channel :

  • Channel Alpha rgba(0,0,0,255) --> Roads
  • Channel Red rgba(255,0,0,0) --> Rivers
  • Channel Green rgba(0,255,0,0) --> Water_areas
  • Channel Blue rgba(0,0,255,0) --> Forest

When I'm analyzing the raster tile (the BINARY not with my eyes) I can't find anymore the value store where as rgb were. I don't need to see them just disable the interpretation of Mapnik (or agg_renderer). I've dig deep inside mapnik github code I found this :

Github - Mapnik: test/unit/imaging/image_premultiply.cpp

It seems to be a function called set_premultiplied_alpha() which could explain why (255,0,0,0) pixel is interpreted as (0,0,0,0).

How can I fix my problem?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.