Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Semi-transparent outlines on raw, premultiplied input #350

Closed
justewg opened this issue Mar 6, 2019 · 3 comments
Closed

Semi-transparent outlines on raw, premultiplied input #350

justewg opened this issue Mar 6, 2019 · 3 comments

Comments

@justewg
Copy link

justewg commented Mar 6, 2019

Thanks for great work, very usefull.
My business task for using tile-server is to show on leaflet/mapbox map three map layers, the lowest is land with some more layers, middle layer is our application data and top layer should contain roads, poi, labels, water regions and should be transparent, of course.
And I have to use raster map mode. So, now my top layer's tiles PNG-images enclose a gray or black substrate under the translucent white color. Result on the attached screenshot.

image

I found that raster files are producing by sharp-library and post the issue to author:
lovell/sharp#1599

Our common investigations point me to the follow: data, passed to sharp-constructor are premultiplied in mapbox-gl-native library.
But I haven't found the solution, where and how I can prevent it.

May be you can help me?

@cgalli
Copy link

cgalli commented Mar 29, 2019

Hey justewg,

Had a similar issue and was able to back out the alpha channel in serve_rendered.js just before the call to sharp. Seems to work. I applied this js to the data object first:

for (var i = 0; i < data.length; i += 4) {
var alpha = data[i + 3];
var norm = alpha / 255;
if (alpha === 0) {
data[i] = 0;
data[i + 1] = 0;
data[i + 2] = 0;
} else {
data[i] = data[i] / norm;
data[i + 1] = data[i + 1] / norm;
data[i + 2] = data[i + 2] / norm;
}
}

Admittedly inspired by consbio/mbgl-renderer@e64af7c after following the issue around. Perhaps that'll help your project get over the hump ours had.

@justewg
Copy link
Author

justewg commented Mar 29, 2019

That works great. Thanks a lot, @cgalli

ivanmart added a commit to ivanmart/tileserver-gl that referenced this issue Apr 7, 2019
ivanmart added a commit to ivanmart/tileserver-gl that referenced this issue Apr 7, 2019
Fix maptiler#350 issue Semi-transparent outlines on raw, premultiplied input
@xabbu42
Copy link
Contributor

xabbu42 commented Aug 16, 2019

Perhaps a pull request could make it easier to get this fixed in the main repo? Or are there other reasons for the delays?

xabbu42 added a commit to xabbu42/tileserver-gl that referenced this issue Jan 28, 2020
petrsloup added a commit that referenced this issue Jan 28, 2020
FIx issue #350 Semi-transparent outlines on raw, premultiplied input
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants