From e6d7ff653d160a4cde917b02d25770686ecc718d Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Sun, 6 Oct 2013 15:46:21 -0400 Subject: [PATCH] fixes for image transparency with PDF output --- core/todo.txt | 2 ++ .../pdf/src/processing/pdf/PGraphicsPDF.java | 18 +++++++----------- todo.txt | 8 ++++++++ 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/core/todo.txt b/core/todo.txt index 187a6ccc1..63785fa5e 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -10,6 +10,8 @@ X https://github.com/processing/processing/issues/2100 X not handled by BufferedReader (or XML parser) X http://stackoverflow.com/questions/10556875/list-of-unicode-characters-that-should-be-filtered-in-output X http://stackoverflow.com/questions/3072152/what-is-unicode-character-2028-ls-line-separator-used-for +X fix image transparency in PDF output +X https://github.com/processing/processing/pull/2070 _ Sort out blending differences with P2D/P3D _ https://github.com/processing/processing/issues/1844 diff --git a/java/libraries/pdf/src/processing/pdf/PGraphicsPDF.java b/java/libraries/pdf/src/processing/pdf/PGraphicsPDF.java index 762a78db7..b49895706 100644 --- a/java/libraries/pdf/src/processing/pdf/PGraphicsPDF.java +++ b/java/libraries/pdf/src/processing/pdf/PGraphicsPDF.java @@ -22,16 +22,13 @@ package processing.pdf; import java.awt.Font; import java.awt.Graphics2D; +import java.awt.Image; import java.io.*; import java.util.*; import com.lowagie.text.*; import com.lowagie.text.pdf.*; -// Tried iText 5, but it was too slow -//import com.itextpdf.text.*; -//import com.itextpdf.text.pdf.*; - import processing.core.*; @@ -405,20 +402,19 @@ public class PGraphicsPDF extends PGraphicsJava2D { protected void imageImpl(PImage image, - float x1, float y1, float x2, float y2, - int u1, int v1, int u2, int v2) { + float x1, float y1, float x2, float y2, + int u1, int v1, int u2, int v2) { pushMatrix(); translate(x1, y1); int imageWidth = image.width; int imageHeight = image.height; scale((x2 - x1) / (float)imageWidth, (y2 - y1) / (float)imageHeight); - if (u2-u1 != imageWidth || v2-v1 != imageHeight) { - PImage tmp = new PImage(u2-u1, v2-v1, ARGB); - tmp.copy(image, u1, v1, u2, v2, 0, 0, u2-u1, v2-v1); - g2.drawImage(image.getImage(), 0, 0, null); + if (u2-u1 == imageWidth && v2-v1 == imageHeight) { + g2.drawImage((Image) image.getNative(), 0, 0, null); } else { - g2.drawImage(image.getImage(), u1, v1, null); + PImage tmp = image.get(u1, v1, u2-u1, v2-v1); + g2.drawImage((Image) tmp.getNative(), 0, 0, null); } popMatrix(); } diff --git a/todo.txt b/todo.txt index 9b9c0f6b9..291fb94dc 100644 --- a/todo.txt +++ b/todo.txt @@ -14,12 +14,20 @@ X https://github.com/processing/processing/pull/2093 X cmd-left is bringing up the text area popup X https://github.com/processing/processing/issues/2103 +_ still having right-click issues +_ https://github.com/processing/processing/issues/2103 + X add appbundler.jar, otherwise folks have to include Xcode _ if they want to build appbundler, they'll need Xcode _ and the command line tools Preferences > Downloads > Command Line Tools _ appbundler will have an NPE if the osx binary isn't built _ also need to have 10.8 version of the SDK (old Xcode won't work) +_ type looks a little feeble on OS X +_ retina problem? may need to turn off (on?) smoothing +_ also need to have a central menubar +_ add the offscreen window hack +_ otherwise mode change causes "do you want to quit?" on OS X _ fix console font on Windows and Linux with 7u40 _ the message area text also looks ugly.. can we fix? _ add pref to select PDE font (so that CJKV languages work better)