You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-commits@xmlgraphics.apache.org by ca...@apache.org on 2007/09/27 14:43:15 UTC
svn commit: r579990 -
/xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/image/GraphicsUtil.java
Author: cam
Date: Thu Sep 27 05:43:14 2007
New Revision: 579990
URL: http://svn.apache.org/viewvc?rev=579990&view=rev
Log:
Avoid NPE when painting a GraphicsNode on to a SVGGraphics2D. Fixes bug 42386.
Modified:
xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/image/GraphicsUtil.java
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/image/GraphicsUtil.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/image/GraphicsUtil.java?rev=579990&r1=579989&r2=579990&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/image/GraphicsUtil.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/image/GraphicsUtil.java Thu Sep 27 05:43:14 2007
@@ -511,6 +511,10 @@
// Check if this is a BufferedImage G2d if so throw an error...
GraphicsConfiguration gc = g2d.getDeviceConfiguration();
+ if (gc == null) {
+ return null;
+ }
+
GraphicsDevice gd = gc.getDevice();
if (WARN_DESTINATION &&
(gd.getType() == GraphicsDevice.TYPE_IMAGE_BUFFER) &&
@@ -525,12 +529,14 @@
public static ColorModel getDestinationColorModel(Graphics2D g2d) {
BufferedImage bi = getDestination(g2d);
- if (bi != null)
+ if (bi != null) {
return bi.getColorModel();
+ }
GraphicsConfiguration gc = g2d.getDeviceConfiguration();
- if (gc == null)
+ if (gc == null) {
return null; // Can't tell
+ }
// We are going to a BufferedImage but no hint was provided
// so we can't determine the destination Color Model.
@@ -556,15 +562,20 @@
public static Rectangle getDestinationBounds(Graphics2D g2d) {
BufferedImage bi = getDestination(g2d);
- if (bi != null)
+ if (bi != null) {
return new Rectangle(0, 0, bi.getWidth(), bi.getHeight());
+ }
GraphicsConfiguration gc = g2d.getDeviceConfiguration();
+ if (gc == null) {
+ return null;
+ }
// We are going to a BufferedImage but no hint was provided
// so we can't determine the destination bounds.
- if (gc.getDevice().getType() == GraphicsDevice.TYPE_IMAGE_BUFFER)
+ if (gc.getDevice().getType() == GraphicsDevice.TYPE_IMAGE_BUFFER) {
return null;
+ }
// This is a JDK 1.3ism, so we will just return null...
// return gc.getBounds();