Created
January 26, 2015 16:50
-
-
Save clafferty-powa/d92890f6d5858730e627 to your computer and use it in GitHub Desktop.
Make all pixels with transparency black, and remove their alpha channel on Android Bitmap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For input image where information is only stored in alpha channel over black RGB. | |
// Make all pixels with transparency black, and remove alpha channel. | |
private Bitmap AlphaToBlack(Bitmap image) { | |
Bitmap rgbImage = image.copy(Bitmap.Config.ARGB_8888, true); | |
for (int y = 0; y < rgbImage.getHeight(); y++) { | |
for (int x = 0; x < rgbImage.getWidth(); x++) { | |
int aPixel = rgbImage.getPixel(x, y); | |
if (rgbImage.getPixel(x, y) < 0xFF000000) | |
rgbImage.setPixel(x, y, 0xFF000000); | |
} | |
} | |
return rgbImage; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment