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

Fix NoData handling in the ColorMethods.color function for the RGB and RGBA Multiband Rasters #3278

Merged
merged 3 commits into from
Aug 4, 2020

Conversation

pomadchin
Copy link
Member

@pomadchin pomadchin commented Aug 1, 2020

Overview

This PR fixes the NoData interpretation by the ColorMethods.color function.
With the current fix for RGBA Rasters the zero would be set only in case the alpha channel is set to 0 as well.
In the RGB case, the alpha channel would be set to zero only when all the 3 bands are filled with nodata values.

Checklist

  • ./CHANGELOG.md updated, if necessary. Link to the issue if closed, otherwise the PR.
  • Unit tests added for bug-fix or new feature

Fix #3203

@pomadchin pomadchin changed the title Fix NoData handling in the color function for the RGB and RGBA Multiband Rasters Fix NoData handling in the ColorMethods.color function for the RGB and RGBA Multiband Rasters Aug 1, 2020
@pomadchin pomadchin force-pushed the fix/rgba-color branch 2 times, most recently from 00c8539 to 8a56a6a Compare August 1, 2020 17:16
Comment on lines +51 to +57
var transparent = true
val r = if (isData(rBand)) { transparent = false; rBand } else 0
val g = if (isData(gBand)) { transparent = false; gBand } else 0
val b = if (isData(bBand)) { transparent = false; bBand } else 0

if(r + g + b == 0) 0
else {
((r & 0xFF) << 24) | ((g & 0xFF) << 16) | ((b & 0xFF) << 8) | 0xFF
}
if(transparent) 0
else ((r & 0xFF) << 24) | ((g & 0xFF) << 16) | ((b & 0xFF) << 8) | 0xFF
Copy link
Member Author

@pomadchin pomadchin Aug 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to make this "transparency" detection cheaper, since this function is applied to all pixels of the raster.

Copy link
Contributor

@CloudNiner CloudNiner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM nice test coverage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

renderJpg() color is bluer than expected
2 participants