From 2c0c1b9a36d0a301bdb4b5be0b62de631118db20 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Fri, 12 Aug 2016 21:34:50 -0400 Subject: [PATCH] bring back getImage() to fix #4473 --- core/src/processing/awt/PGraphicsJava2D.java | 10 ++++++++++ core/src/processing/core/PImage.java | 2 +- core/todo.txt | 8 ++------ .../libraries/pdf/src/processing/pdf/PGraphicsPDF.java | 2 +- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/core/src/processing/awt/PGraphicsJava2D.java b/core/src/processing/awt/PGraphicsJava2D.java index 213dfbbfe..325563526 100644 --- a/core/src/processing/awt/PGraphicsJava2D.java +++ b/core/src/processing/awt/PGraphicsJava2D.java @@ -253,6 +253,16 @@ public class PGraphicsJava2D extends PGraphics { } + /** + * Still need a means to get the java.awt.Image object, since getNative() + * is going to return the {@link Graphics2D} object. + */ + @Override + public Image getImage() { + return image; + } + + /** Returns the java.awt.Graphics2D object used by this renderer. */ @Override public Object getNative() { diff --git a/core/src/processing/core/PImage.java b/core/src/processing/core/PImage.java index d0c1940f6..cc1105322 100644 --- a/core/src/processing/core/PImage.java +++ b/core/src/processing/core/PImage.java @@ -345,8 +345,8 @@ public class PImage implements PConstants, Cloneable { /** * Use the getNative() method instead, which allows library interfaces to be * written in a cross-platform fashion for desktop, Android, and others. + * This is still included for PGraphics objects, which may need the image. */ - @Deprecated public Image getImage() { // ignore return (Image) getNative(); } diff --git a/core/todo.txt b/core/todo.txt index afdd11b3d..c1b13a4e7 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -2,6 +2,7 @@ X some Table cleanup based on other CSV parsing work X use StandardCharsets.UTF_8 instead of getting encoding by name X PApplet.main(Blah.class) now works +o add push() and pop() methods to mirror js? X add toJSON() method to IntDict X had to use JSONObject.quote() to wrap the text _ do the same for the other data classes @@ -19,7 +20,7 @@ X https://github.com/processing/processing/issues/4265 X https://github.com/processing/processing/pull/4268 -_ disable OpenGL ES on Linux? +_ option to disable OpenGL ES on Linux? _ https://github.com/processing/processing/issues/4584 _ Can't render PGraphics object using image() within a PDF @@ -33,10 +34,6 @@ _ textAlign(CENTER) and pixelDensity(2) aligning incorrectly with Java2D _ https://github.com/processing/processing/issues/4020 _ add increment() that takes IntDict to merge things -_ normalize error messages for missing files -_ https://github.com/processing/processing/issues/4265 -_ https://github.com/processing/processing/pull/4268 - _ should fullScreen() set width and height to displayWidth/Height _ or is that being set/unset used for any state info? _ when calling exit(), if sketch has halted w/ exception, force the quit @@ -45,7 +42,6 @@ _ simple test case: using size() inside setup() from Eclipse discussion -_ add push() and pop() methods to mirror js? _ how to handle the touch api _ figure our size(img.width, img.height) situation _ just make loadImage() work in settings diff --git a/java/libraries/pdf/src/processing/pdf/PGraphicsPDF.java b/java/libraries/pdf/src/processing/pdf/PGraphicsPDF.java index 606449acd..a84c6108f 100644 --- a/java/libraries/pdf/src/processing/pdf/PGraphicsPDF.java +++ b/java/libraries/pdf/src/processing/pdf/PGraphicsPDF.java @@ -423,7 +423,7 @@ public class PGraphicsPDF extends PGraphicsJava2D { scale((x2 - x1) / imageWidth, (y2 - y1) / imageHeight); if (u2-u1 == imageWidth && v2-v1 == imageHeight) { - g2.drawImage((Image) image.getNative(), 0, 0, null); + g2.drawImage(image.getImage(), 0, 0, null); } else { PImage tmp = image.get(u1, v1, u2-u1, v2-v1); g2.drawImage((Image) tmp.getNative(), 0, 0, null);