Created
October 14, 2020 18:22
-
-
Save Mr00Anderson/bea98dab3c768df03a3b9d35da7d9f25 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
//Overlays using pixel from base images and making a percent darker | |
public static Pixmap combineImages(final Pixmap basePixmap, final Pixmap overlayPixmap) { | |
final Pixmap newPixmap = new Pixmap(basePixmap.getWidth(), basePixmap.getHeight(), basePixmap.getFormat()); | |
final int adjustedWidthIndex = basePixmap.getWidth(); | |
final int adjustedHeightIndex = basePixmap.getHeight(); | |
for (int row = 0; row < adjustedHeightIndex; row++) { | |
for (int column = 0; column < adjustedWidthIndex; column++) { | |
final int basePixel = basePixmap.getPixel(column, row); | |
final int overlayPixel = overlayPixmap.getPixel(column, row); | |
if (isTranslucent(overlayPixel)) { | |
newPixmap.drawPixel(column, row, 0); /* Set translucent if is translucent color*/ | |
} else if (overlayPixel == 0) { | |
newPixmap.drawPixel(column, row, basePixel); | |
} else { | |
newPixmap.drawPixel(column, row, overlayPixel); | |
} | |
} | |
} | |
return newPixmap; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment