Skip to content

Commit 390bd75

Browse files
committed
Apply alpha channel after adding the image data via _out()
1 parent 1bb5705 commit 390bd75

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/main/java/com/koadweb/javafpdf/FPDF.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1902,11 +1902,6 @@ protected void Image(final String file, byte[] data, Coordinate coords, final fl
19021902
info = this.images.get(file);
19031903
}
19041904

1905-
// if the image has an alpha mask, add it separately
1906-
if (info.containsKey("alphaMask")) {
1907-
this.Image("alphaMask-" + file, (byte[])info.get("alphaMask"), new Coordinate(0, 0), 0, 0, ImageType.PNG, 0, true);
1908-
}
1909-
19101905
// masks are grayscale, regardless of what it claims
19111906
if (isMask) {
19121907
info.put("cs", "DeviceGray");
@@ -1942,6 +1937,13 @@ protected void Image(final String file, byte[] data, Coordinate coords, final fl
19421937
if (link > 0) {
19431938
this.Link(coords.getX(), coords.getY(), w1, h1, link);
19441939
}
1940+
1941+
// if the image has an alpha mask, add it separately
1942+
// Also note, the alphaMask must be applied AFTER the call to _out()
1943+
// otherwise you'll get corrupted PDFs and be really confused
1944+
if (info.containsKey("alphaMask")) {
1945+
this.Image("alphaMask-" + file, (byte[])info.get("alphaMask"), new Coordinate(0, 0), 0, 0, ImageType.PNG, 0, true);
1946+
}
19451947
}
19461948

19471949
/**

0 commit comments

Comments
 (0)