|
22 | 22 |
|
23 | 23 | import java.awt.Font; |
24 | 24 | import java.awt.Graphics2D; |
| 25 | +import java.awt.Image; |
25 | 26 | import java.io.*; |
26 | 27 | import java.util.*; |
27 | 28 |
|
28 | 29 | import com.lowagie.text.*; |
29 | 30 | import com.lowagie.text.pdf.*; |
30 | 31 |
|
31 | | -// Tried iText 5, but it was too slow |
32 | | -//import com.itextpdf.text.*; |
33 | | -//import com.itextpdf.text.pdf.*; |
34 | | - |
35 | 32 | import processing.core.*; |
36 | 33 |
|
37 | 34 |
|
@@ -405,20 +402,19 @@ public void clear() { |
405 | 402 |
|
406 | 403 |
|
407 | 404 | protected void imageImpl(PImage image, |
408 | | - float x1, float y1, float x2, float y2, |
409 | | - int u1, int v1, int u2, int v2) { |
| 405 | + float x1, float y1, float x2, float y2, |
| 406 | + int u1, int v1, int u2, int v2) { |
410 | 407 | pushMatrix(); |
411 | 408 | translate(x1, y1); |
412 | 409 | int imageWidth = image.width; |
413 | 410 | int imageHeight = image.height; |
414 | 411 | scale((x2 - x1) / (float)imageWidth, |
415 | 412 | (y2 - y1) / (float)imageHeight); |
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); |
| 413 | + if (u2-u1 == imageWidth && v2-v1 == imageHeight) { |
| 414 | + g2.drawImage((Image) image.getNative(), 0, 0, null); |
420 | 415 | } else { |
421 | | - g2.drawImage(image.getImage(), u1, v1, null); |
| 416 | + PImage tmp = image.get(u1, v1, u2-u1, v2-v1); |
| 417 | + g2.drawImage((Image) tmp.getNative(), 0, 0, null); |
422 | 418 | } |
423 | 419 | popMatrix(); |
424 | 420 | } |
|
0 commit comments