summaryrefslogtreecommitdiffstats
path: root/src/classes/share/com
diff options
context:
space:
mode:
authorChien Yang <[email protected]>2006-11-02 00:51:41 +0000
committerChien Yang <[email protected]>2006-11-02 00:51:41 +0000
commit52f71fb7df6e3376ca5d934e1052ea59fc9f40f9 (patch)
tree9df2ccac0c96a69a6f52c0d4006f7f9400bff2a8 /src/classes/share/com
parent082a4ff7e99865ec86ee755af327bdc3bd46ff22 (diff)
Fixed Issue 360 : SceneGraphStreamWriter.writeBranchGraph throws exception
git-svn-id: https://svn.java.net/svn/j3d-core-utils~svn/trunk@133 9497e636-51bd-65ba-982d-a4982e1767a5
Diffstat (limited to 'src/classes/share/com')
-rw-r--r--src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/ImageComponentState.java29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/ImageComponentState.java b/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/ImageComponentState.java
index 7f320e1..dd883bd 100644
--- a/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/ImageComponentState.java
+++ b/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/ImageComponentState.java
@@ -145,8 +145,32 @@ public abstract class ImageComponentState extends NodeComponentState {
private void writeBufferedImageNoCompression( DataOutput out, BufferedImage image ) throws IOException {
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
DataOutputStream dataOut = new DataOutputStream( byteStream );
+ ColorModel colorModel = (ColorModel) image.getColorModel();
- writeColorModel( dataOut, image.getColorModel() );
+ if (colorModel instanceof ComponentColorModel) {
+ ComponentColorModel cm = (ComponentColorModel) colorModel;
+ int numComponents = cm.getNumComponents();
+ int type;
+ switch (numComponents) {
+ case 3:
+ type = BufferedImage.TYPE_INT_RGB;
+ break;
+ case 4:
+ type = BufferedImage.TYPE_INT_ARGB;
+ break;
+ default:
+ throw new SGIORuntimeException("Unsupported ColorModel "+colorModel.getClass().getName() );
+
+ }
+
+ BufferedImage tmpBuf = new BufferedImage(image.getWidth(), image.getHeight(), type);
+ WritableRaster dstRaster = tmpBuf.getRaster();
+ Raster srcRaster = image.getRaster();
+ dstRaster.setRect(srcRaster);
+ image = tmpBuf;
+ }
+
+ writeColorModel( dataOut, image.getColorModel() );
writeWritableRaster( dataOut, image.getRaster() );
dataOut.writeBoolean( image.isAlphaPremultiplied() );
@@ -248,7 +272,8 @@ public abstract class ImageComponentState extends NodeComponentState {
if (colorModel instanceof DirectColorModel) {
out.writeInt( DIRECT_COLOR_MODEL );
writeDirectColorModel( out, (DirectColorModel)colorModel );
- } else
+ }
+ else
throw new SGIORuntimeException("Unsupported ColorModel "+colorModel.getClass().getName() );
}