Skip to content

Commit ebf7bda

Browse files
committed
fixes for image transparency with PDF output
1 parent 6131a3a commit ebf7bda

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

core/todo.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ X https://github.com/processing/processing/issues/2100
1010
X not handled by BufferedReader (or XML parser)
1111
X http://stackoverflow.com/questions/10556875/list-of-unicode-characters-that-should-be-filtered-in-output
1212
X http://stackoverflow.com/questions/3072152/what-is-unicode-character-2028-ls-line-separator-used-for
13+
X fix image transparency in PDF output
14+
X https://github.com/processing/processing/pull/2070
1315

1416
_ Sort out blending differences with P2D/P3D
1517
_ https://github.com/processing/processing/issues/1844

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

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,13 @@
2222

2323
import java.awt.Font;
2424
import java.awt.Graphics2D;
25+
import java.awt.Image;
2526
import java.io.*;
2627
import java.util.*;
2728

2829
import com.lowagie.text.*;
2930
import com.lowagie.text.pdf.*;
3031

31-
// Tried iText 5, but it was too slow
32-
//import com.itextpdf.text.*;
33-
//import com.itextpdf.text.pdf.*;
34-
3532
import processing.core.*;
3633

3734

@@ -405,20 +402,19 @@ public void clear() {
405402

406403

407404
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) {
410407
pushMatrix();
411408
translate(x1, y1);
412409
int imageWidth = image.width;
413410
int imageHeight = image.height;
414411
scale((x2 - x1) / (float)imageWidth,
415412
(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);
420415
} 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);
422418
}
423419
popMatrix();
424420
}

todo.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,20 @@ X https://github.com/processing/processing/pull/2093
1414
X cmd-left is bringing up the text area popup
1515
X https://github.com/processing/processing/issues/2103
1616

17+
_ still having right-click issues
18+
_ https://github.com/processing/processing/issues/2103
19+
1720
X add appbundler.jar, otherwise folks have to include Xcode
1821
_ if they want to build appbundler, they'll need Xcode
1922
_ and the command line tools Preferences > Downloads > Command Line Tools
2023
_ appbundler will have an NPE if the osx binary isn't built
2124
_ also need to have 10.8 version of the SDK (old Xcode won't work)
2225

26+
_ type looks a little feeble on OS X
27+
_ retina problem? may need to turn off (on?) smoothing
28+
_ also need to have a central menubar
29+
_ add the offscreen window hack
30+
_ otherwise mode change causes "do you want to quit?" on OS X
2331
_ fix console font on Windows and Linux with 7u40
2432
_ the message area text also looks ugly.. can we fix?
2533
_ add pref to select PDE font (so that CJKV languages work better)

0 commit comments

Comments
 (0)