Skip to content

Commit 3246763

Browse files
committed
Merge pull request #4 from bstoots/png-alpha-channel-fix
Apply alpha channel after adding the image data via _out()
2 parents 460e971 + 390bd75 commit 3246763

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
@@ -1910,11 +1910,6 @@ protected void Image(final String file, byte[] data, Coordinate coords, final fl
19101910
info = this.images.get(file);
19111911
}
19121912

1913-
// if the image has an alpha mask, add it separately
1914-
if (info.containsKey("alphaMask")) {
1915-
this.Image("alphaMask-" + file, (byte[])info.get("alphaMask"), new Coordinate(0, 0), 0, 0, ImageType.PNG, 0, true);
1916-
}
1917-
19181913
// masks are grayscale, regardless of what it claims
19191914
if (isMask) {
19201915
info.put("cs", "DeviceGray");
@@ -1950,6 +1945,13 @@ protected void Image(final String file, byte[] data, Coordinate coords, final fl
19501945
if (link > 0) {
19511946
this.Link(coords.getX(), coords.getY(), w1, h1, link);
19521947
}
1948+
1949+
// if the image has an alpha mask, add it separately
1950+
// Also note, the alphaMask must be applied AFTER the call to _out()
1951+
// otherwise you'll get corrupted PDFs and be really confused
1952+
if (info.containsKey("alphaMask")) {
1953+
this.Image("alphaMask-" + file, (byte[])info.get("alphaMask"), new Coordinate(0, 0), 0, 0, ImageType.PNG, 0, true);
1954+
}
19531955
}
19541956

19551957
/**

0 commit comments

Comments
 (0)