Mapbox-gl-js: Rendering error when a transparent image is added via Map#addImage

Created on 3 Apr 2017  ·  5Comments  ·  Source: mapbox/mapbox-gl-js

After release 0.34.0 I was playing with Map#addImage functionality, trying to load images as icons. I added simple png image with transparent background and notice weird white outline, which appeared around it.

For example I cropped rocket from file, which is being loaded for sprites. d2ayr08pmg00aaaaaelftksuqmcc
And tried to add it to Map: (left is loaded manually, right is yours)
2017-04-03 20 19 18
Mapbox genereted very poor white outline for this icon.
Here is JSBin for reference:

How I can improve quality of loaded image?

mapbox-gl-js version: v0.34.0

Expected Behavior

Mapbox load image with same outlines as original image, which was loaded.

Actual Behavior

Mapbox add it's own outlines.

bug good first issue

Most helpful comment

addImage needs to premultiply the image data before copying it into the texture, as is done by ImageSprite.

All 5 comments

Thanks for the report and the test case, @ozeron!

At first glance, it looks to me like addImage is not handling the transparency of the image properly.

addImage needs to premultiply the image data before copying it into the texture, as is done by ImageSprite.

@jfirebaugh Thank you, premultiplying image data fixes this issue 👍
Still it is looks like a bug.

@ozeron agreed, still a bug!

This blocker prevents us from releasing a variety of new overlays. The most critical overlays in that group pertain to traffic incidents and severe storm tracks.

Any timeline for fixing?

Was this page helpful?
0 / 5 - 0 ratings