Merge pull request #2645 from JakubValtar/blend-fix

Fixes blending operations in Java2D
This commit is contained in:
Ben Fry
2014-07-25 16:45:49 -04:00
@@ -743,11 +743,14 @@ public class PGraphicsJava2D extends PGraphics {
int[] srcPixels = new int[width];
int[] dstPixels = new int[width];
// Java won't set the high bits when RGB, returns 0 for alpha
int alphaFiller = (dstIn.getNumBands() == 3) ? (0xFF << 24) : 0x00;
for (int y = 0; y < height; y++) {
src.getDataElements(0, y, width, 1, srcPixels);
dstIn.getDataElements(0, y, width, 1, dstPixels);
for (int x = 0; x < width; x++) {
dstPixels[x] = blendColor(srcPixels[x], dstPixels[x], mode);
dstPixels[x] = blendColor(srcPixels[x], alphaFiller | dstPixels[x], mode);
}
dstOut.setDataElements(0, y, width, 1, dstPixels);
}
@@ -1671,7 +1674,7 @@ public class PGraphicsJava2D extends PGraphics {
if (textFont == null) {
defaultFontOrDeath("textWidth");
}
Font font = (Font) textFont.getNative();
//if (font != null && (textFont.isStream() || hints[ENABLE_NATIVE_FONTS])) {
if (font != null) {