aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/share/javax
diff options
context:
space:
mode:
authorChien Yang <[email protected]>2006-12-20 19:13:04 +0000
committerChien Yang <[email protected]>2006-12-20 19:13:04 +0000
commitaf4b6470b766c0656260377e21b64529fbf61839 (patch)
tree48bef54d943db95fd106abb866b9a54178a7bf51 /src/classes/share/javax
parent70813c84f7b1cc3587085a3bcc4c90a44ee0a886 (diff)
Fixed issue 425 : NullPointerException in automatic mipmap generation
git-svn-id: https://svn.java.net/svn/j3d-core~svn/trunk@764 ba19aa83-45c5-6ac9-afd3-db810772062c
Diffstat (limited to 'src/classes/share/javax')
-rw-r--r--src/classes/share/javax/media/j3d/ImageComponent2DRetained.java30
1 files changed, 28 insertions, 2 deletions
diff --git a/src/classes/share/javax/media/j3d/ImageComponent2DRetained.java b/src/classes/share/javax/media/j3d/ImageComponent2DRetained.java
index 4e2d13b..75835d3 100644
--- a/src/classes/share/javax/media/j3d/ImageComponent2DRetained.java
+++ b/src/classes/share/javax/media/j3d/ImageComponent2DRetained.java
@@ -332,14 +332,40 @@ class ImageComponent2DRetained extends ImageComponentRetained {
} else {
newHeight = 1;
yScale = 1;
- }
+ }
+
+ // XXXXX Fix to Issue 425 : NullPointerException in automatic mipmap generation
+ if (imageData == null) {
+ // This is a byRef, support format and is a RenderedImage case.
+ // See ImageComponent2DRetained.set(RenderedImage image)
+ RenderedImage ri = (RenderedImage) getRefImage(0);
+
+ assert !(ri instanceof BufferedImage);
+
+ // Create a buffered image from renderImage
+ ColorModel cm = ri.getColorModel();
+ WritableRaster wRaster = ri.copyData(null);
+ ri = new BufferedImage(cm,
+ wRaster,
+ cm.isAlphaPremultiplied()
+ ,null);
+
+
+ // Create image data object with buffer for image. */
+ imageData = createRenderedImageDataObject(null);
+ copySupportedImageToImageData(ri, 0, imageData);
+
+ }
+
+ assert imageData != null;
+ // XXXXX
ImageComponent2DRetained newImage = new ImageComponent2DRetained();
newImage.processParams(getFormat(), newWidth, newHeight, 1);
newImage.setImageFormatType(getImageFormatType());
newImage.setUnitsPerPixel(getUnitsPerPixel());
newImage.imageData = newImage.createRenderedImageDataObject(null);
-
+
newImage.scaleImage(xScale, yScale, 0, this);
return newImage;