X Tutup
Skip to content

Commit f25e957

Browse files
committed
Image transparency for PDF output
Before, drawing an image with transparency would result in black, opaque pixels in the PDF file. This change, figured out together with Jürg Lehni, fixes this. At its core, switching from drawImage(img, int, int, int, int, int, int, int, int, null) to drawImage(img, int, int, null) seems to do the trick - so this might have been a bug in iText all along. Signed-off-by: Jürg Lehni <juerg@scratchdisk.com> Signed-off-by: Gottfried Haider <gottfried.haider@gmail.com>
1 parent 6e508f4 commit f25e957

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

java/libraries/pdf/src/processing/pdf/PGraphicsPDF.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -404,22 +404,18 @@ public void clear() {
404404
//////////////////////////////////////////////////////////////
405405

406406

407-
/*
408-
protected void imageImplAWT(java.awt.Image awtImage,
407+
protected void imageImpl(PImage image,
409408
float x1, float y1, float x2, float y2,
410409
int u1, int v1, int u2, int v2) {
411410
pushMatrix();
412411
translate(x1, y1);
413-
int awtImageWidth = awtImage.getWidth(null);
414-
int awtImageHeight = awtImage.getHeight(null);
415-
scale((x2 - x1) / (float)awtImageWidth,
416-
(y2 - y1) / (float)awtImageHeight);
417-
g2.drawImage(awtImage,
418-
0, 0, awtImageWidth, awtImageHeight,
419-
u1, v1, u2, v2, null);
412+
int imageWidth = image.width;
413+
int imageHeight = image.height;
414+
scale((x2 - x1) / (float)imageWidth,
415+
(y2 - y1) / (float)imageHeight);
416+
g2.drawImage(image.getImage(), u1, v1, null);
420417
popMatrix();
421418
}
422-
*/
423419

424420

425421
//////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)
X Tutup