Skip to content

Commit 075b7e5

Browse files
committed
Filling in missing alpha for blending operations
Fixes processing#2012, fixes processing#2275. It's the same problem as processing#2030 - Java won't set the high bits when RGB, returns 0 for alpha in BlendingContext#compose(Raster, Raster, WritableRaster)
1 parent ad072ea commit 075b7e5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

core/src/processing/core/PGraphicsJava2D.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -743,11 +743,14 @@ public void compose(Raster src, Raster dstIn, WritableRaster dstOut) {
743743
int[] srcPixels = new int[width];
744744
int[] dstPixels = new int[width];
745745

746+
// Java won't set the high bits when RGB, returns 0 for alpha
747+
int alphaFiller = (dstIn.getNumBands() == 3) ? (0xFF << 24) : 0x00;
748+
746749
for (int y = 0; y < height; y++) {
747750
src.getDataElements(0, y, width, 1, srcPixels);
748751
dstIn.getDataElements(0, y, width, 1, dstPixels);
749752
for (int x = 0; x < width; x++) {
750-
dstPixels[x] = blendColor(srcPixels[x], dstPixels[x], mode);
753+
dstPixels[x] = blendColor(srcPixels[x], alphaFiller | dstPixels[x], mode);
751754
}
752755
dstOut.setDataElements(0, y, width, 1, dstPixels);
753756
}
@@ -1671,7 +1674,7 @@ protected float textWidthImpl(char buffer[], int start, int stop) {
16711674
if (textFont == null) {
16721675
defaultFontOrDeath("textWidth");
16731676
}
1674-
1677+
16751678
Font font = (Font) textFont.getNative();
16761679
//if (font != null && (textFont.isStream() || hints[ENABLE_NATIVE_FONTS])) {
16771680
if (font != null) {

0 commit comments

Comments
 (0)