Skip to content

Commit 58e53a8

Browse files
committed
Add support for custom source regions in imageImpl
As suggested by Ben
1 parent f25e957 commit 58e53a8

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,13 @@ protected void imageImpl(PImage image,
413413
int imageHeight = image.height;
414414
scale((x2 - x1) / (float)imageWidth,
415415
(y2 - y1) / (float)imageHeight);
416-
g2.drawImage(image.getImage(), u1, v1, null);
416+
if (u2-u1 != imageWidth || v2-v1 != imageHeight) {
417+
PImage tmp = new PImage(u2-u1, v2-v1, ARGB);
418+
tmp.copy(image, u1, v1, u2, v2, 0, 0, u2-u1, v2-v1);
419+
g2.drawImage(image.getImage(), 0, 0, null);
420+
} else {
421+
g2.drawImage(image.getImage(), u1, v1, null);
422+
}
417423
popMatrix();
418424
}
419425

0 commit comments

Comments
 (0)